Closed MirabellelaTerreur closed 4 years ago
pyWeightAndBalance
is a fairly deprecated module. What are you trying to use it for?
Thank you for your attention, well, pyWeightAndBalance.py is not my real problem, my real problem is in the code listed below.
Myself, I am trying to run an aerodynamic simulation analysis of a wing.
I used adflow pyWeightAndBalance.py just for testing the same problem, following the advice from a very kind forum moderator at python-forum.io :
"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."
My problem is in the code below, so I began to ask around the python community, me 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 and failing because mdoimport help is missing."
There is nothing named mdo_import_helper that comes with Python. So I thought it was some sort of dependency of the code I am trying to run; unfortunately, no instructions just an error :
ModuleNotFoundError : No module named 'mdo_import_helper'
Here is the source of my real problem, (under Part 1.2 quoted below) :
from mdo_import_helper import *
exec(import_modules('pySpline', 'tripan', 'functions'))
# =======================================================================================
# 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)
Hi Mirabelle, I'm closing this in favour of email communications since this seems pretty specific to your case.
Hello,
I'm a student in aeronautics from France, a bit of experience with python, and doing a group job for a glider design project.
While testing and trying to run your adflow/pyWeightAndBalance.py I keep failing because extension module mdo_import_help is missing.
I'm getting the error message: ModuleNotFoundError : No module named 'mdo_import_helper'
I cannot find anything named mdo_import_helper that comes with Python.
Is mdo_import_help some sort of a dependency of your code, which I'm trying to run ?
Hopefully some instructions could tell me exactly what else I need to install and to be able to use it.
Thank you very much,
Mirabelle