Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
mdo_import_help
#1
Hi, all,

I'm a new user, also a python newbie,
hoping to learn here from the wisdom and
experience of other members.

Now, anyone is familiar with mdo_import_help ?
I'm trying to run some python code code but it
keeps failing because mdo_import_ help is missing.

Thanks, guys

Mirabelle la terreur
Reply
#2
Hello Mirabelle, where does your code come from? I've never heard of this module. Also can you post the complete error traceback?
Reply
#3
Thank you !

So, here's da thingie, as seen under Spyder Python 3.7 :

Problem is (under Part 1.2 quoted below) :
from mdo_import_helper import *
exec(import_modules('pySpline', 'tripan', 'functions'))

Error:
ModuleNotFoundError : No module named 'mdo_import_helper'
Code :
# =======================================================================================
# Aerodynamic Analysis of a Wing
# =======================================================================================
# A generic semi-tappered wing is used for this example
# =======================================================================================
# Aerodynamic Analysis With Tripan Flow Solver
# =======================================================================================
# Part 1 : Importing Standard Python Modules
import os, sys, string, pdb, copy, time, string, re, numpy, datetime
# Set the beginning of the timer for code
t0 = datetime.datetime.now()

# _______________________________________________________________________________________
# Part 1.1 : Importing External Python Modules and setting of broadcasting variable
from mpi4py import MPI
comm = MPI.COMM_WORLD

# _______________________________________________________________________________________
# Part 1.2 : Importing Extension modules and initializing 'comm' variables
from mdo_import_helper import *
exec(import_modules('pySpline', 'tripan', 'functions'))

# _______________________________________________________________________________________
# Part 1.3 : Defining the folder for the results output
prefix = './results'
for arg in sys.argv:
    # Find the prefix from the command line arguments
    m = re.match('(prefix=)(.*)', arg)
    if m:
        prefix = m.group(2)
# Create a new directory and broadcast it to everything
if os.path.isdir(prefix):
    i = 1
    while os.path.isdir(os.path.join(prefix, 'Aero_Analysis_Num%d'%(i))):
        i = i+1
    prefix = os.path.join(prefix, 'Aero_Analysis_Num%d'%(i))
    os.mkdir(prefix)
    prefix = prefix + os.sep
else:
    print('Prefix is not a directory!')
prefix = MPI.COMM_WORLD.bcast(prefix, root=0)
print ('Using prefix = %s'%(prefix))

# =======================================================================================
# Part 2 : Defining The Functions to set up the Tripan Object
def setUpTriPanWing(comm, trifile='geo/wing.tripan', wakefile='geo/wing.edge'):
    # Set up TriPan using the files
    ndownstream = 100
    sym_direction = 2 # Use symmetry about the z-axis
    down_dist = 150.0
    time_dependent = 0 # A steady state simulation
    a_wake_dir = numpy.zeros(3)
    b_wake_dir = numpy.zeros(3)
    a_wake_dir[1] = 1.0
    b_wake_dir[2] = 1.0
    # Stretch the wake downstream
    wake_history = tripan.WakeHistory(ndownstream, down_dist, tripan.WakeHistory.STRETCHED)
    triPan = tripan.TriPanel(comm, trifile, wakefile, wake_history, time_dependent, ndownstream, a_wake_dir, b_wake_dir, sym_direction)
    npanels = triPan.getNumPanels()
    triPan.setPCSizes(1.5, 150*npanels)
    print('TriPan panels', npanels)
    return triPan

# =======================================================================================
# Part 3 : Core of the Script for Aerodynamic Analysis With Tripan Flow Solver
# _______________________________________________________________________________________
# Part 3.1 : Setting Up the Tripan Flow Solver
# Defining The Names for the Tripan Input Files
trifile = 'geo/wing_50x100.tripan'; wakefile = 'geo/wing_50x100.wake'
edgefile = 'geo/wing_50x100.edge';
# Set Up Tripan Object
triPan = setUpTriPanWing(comm, trifile=trifile, wakefile=wakefile)
edgeinfo = tripan.TriPanEdgeInfo(edgefile)
# Set Up Tripan Solver
n_flight_cons = 1
triOpt = tripan.TriPanOpt(triPan, n_flight_cons)

# _______________________________________________________________________________________
# Part 3.2 : Defining The Design Parameters for the Atmosphere properties
Semi_Span = 15/2
# Generic atmospheric conditions for 1000m , 25 m/s with MAC as reference length
Minf = 0.0743                   # Incompressible Mach number
rho = 1.11164                   # Air density kg/m^3
ainf = 336.4379                 # Speed of sound m/s
alpha = (4.0/180.0)*numpy.pi    # Angle of attack
Vinf = Minf*ainf                # Air speed
Qinf = 0.5*rho*Vinf**2          # Dynamic Pressure

# _______________________________________________________________________________________
# Part 3.3 : Solving the Aerodynamic System
# Function to get the Wing Area to compute coefficients
area_func = tripan.TriPanProjectedArea()
Area_ref = area_func.evalFunction(triPan)
print('Area_Tripan = ', Area_ref)
# Setting the Load Case, the Wing Angle of Attack and Flight Condition
load_case = 0
alpha_num = 0
fcon = tripan.FlightCondition(rho, Minf, Vinf, alpha, alpha_num, load_case)
triOpt.addFlightCondition(0, fcon)
triOpt.setFlightCondition(0)
# Setting the options for the Generalized Minimal Residual Method (GMRES) Solver
gmres_iters = 60
max_iters = 5*gmres_iters
triOpt.setGMRESIters(gmres_iters, max_iters)
triOpt.monitor()
# Solve the aerodynamic problem
triOpt.solve()

# _______________________________________________________________________________________
# Part 3.4 : Setting Up the Solution Output Files
# Setting the names for the Output Files
obj_aero_name = prefix+'wing_obj_aero.dat'
tecplot_sol_name = prefix+'wing_tripan_solution.dat'
wake_sol_name = prefix+'wing_wake_file.dat'
load_file_name = 'load_data/wing_aero_load.dat'
lift_dist_name = prefix+'wing_lift_dist.dat'
# Generating Surface solution output
triOpt.writeAeroFile(obj_aero_name)
# Generating .dat Tacplot Visualization files
out_type = 1
triPan.writeSeqTecplotFile(tecplot_sol_name, -1.0, out_type)
triPan.writeWakeFile(wake_sol_name)
# Generating Load data
triPan.writeAeroForceFile(Winf, load_file_name)
# Generating lift distribution graph
Zloc = numpy.linspace(0.01, Semi_Span)
triPan.writeLiftDistribution(lift_dist_name, Zloc)
# Evaluation of aerodynamic functions
lift_func = tripan.TriPanLift()
drag_func = tripan.TriPanDrag()
lift = triOpt.evalAeroFunc(lift_func)
drag = triOpt.evalAeroFunc(drag_func)
# Writing some outputs for user visualization
print('Lift = ', lift*Qinf*2)
print('Drag = ', drag*Qinf*2)
print('CL = ', (lift/Area_ref)*2)
print('CD = ', (drag/Area_ref)*2)
final_time = datetime.datetime.now()-t0
print('Total time spent in the aerodynamic analysis: ', final_time)
Reply
#4
A search with the keyword mdo_import_helper leads to a masters thesis containing listings similar to your code. The author Bruno Cadete may be using his own python modules. The best thing to do would be to email him about his code.
Reply
#5
Sorry about my mistakes, I will gladly follow BBCode discipline in the future. And thank you for your answer, well, WOW! This solves the thing, indeed; I will try to get in touch with Bruno Cadete, now is clear where from my professor got the code he gave us. Thanks a lot, again, Mirabelle la Terreur
Reply
#6
It seems that the line import mdo_import_helper appears in the project mdolab/adflow, for example see adflow/pyWeightAndBalance.py. If you can install this software, you may find where the mdo_import_helper module comes from.
Reply
#7
Amazing discovery, thanks; and no, I also cannot run that adflow module, but, I will join github and will certainly ask the guys behind mdolab/adflow/pyWeightAndBalance.py about this issue with mdo_import_helper, because as you brilliantly discovered, it is also exactly there...
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020