Skip to content

Commit

Permalink
Merge pull request #342 from suavecode/feature-tut_fixes
Browse files Browse the repository at this point in the history
Feature tut fixes
  • Loading branch information
planes authored Mar 22, 2020
2 parents 3af5e7c + 5536b10 commit 93ef42a
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 21 deletions.
2 changes: 1 addition & 1 deletion doc/suave_config
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ PROJECT_NAME = SUAVE
# could be handy for archiving the generated documentation or if some version
# control system is used.

PROJECT_NUMBER = 2.0.0
PROJECT_NUMBER = 2.1.0

# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
Expand Down
8 changes: 8 additions & 0 deletions trunk/SUAVE/Components/Energy/Converters/Motor_Lo_Fid.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@
# Created: Jun 2014, E. Botero
# Modified: Jan 2016, T. MacDonald
# Mar 2020, M. Clarke
# Mar 2020, E. Botero

# ----------------------------------------------------------------------
# Imports
# ----------------------------------------------------------------------

import numpy as np

# suave imports
import SUAVE

Expand Down Expand Up @@ -100,6 +103,11 @@ def omega(self,conditions):

# Omega
omega1 = (Kv*v)/2. + (Kv*(Res*Res*io*io - 2.*Res*etam*io*v - 2.*Res*io*v + etam*etam*v*v - 2.*etam*v*v + v*v)**(1./2.))/2. - (Kv*Res*io)/2. + (Kv*etam*v)/2.

# If the voltage supplied is too low this function will NaN. However, that really means it won't spin
omega1[np.isnan(omega1)] = 0.0

# The torque
Q = ((v-omega1/Kv)/Res -io)/Kv

omega1[v==0] = 0.
Expand Down
4 changes: 2 additions & 2 deletions trunk/SUAVE/Input_Output/SU2/call_SU2_CFD.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ def call_SU2_CFD(tag,parallel=False,processors=1):

# Lift and Drag

CL = float(final_state[1])
CD = float(final_state[2])
CL = float(final_state[9])
CD = float(final_state[8])

SU2_results.coefficient_of_lift = CL
SU2_results.coefficient_of_drag = CD
Expand Down
32 changes: 19 additions & 13 deletions trunk/SUAVE/Input_Output/SU2/write_SU2_cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# Created: Oct 2016, T. MacDonald
# Modified: Jan 2017, T. MacDonald
# Mar 2018, T. MacDonald
# Mar 2020, E. Botero

## @ingroup Input_Output-SU2
def write_SU2_cfg(tag,SU2_settings):
Expand Down Expand Up @@ -40,9 +41,14 @@ def write_SU2_cfg(tag,SU2_settings):
f = open(filename,mode='w')

# Problem definition
f.write('PHYSICAL_PROBLEM = EULER\n\n')
f.write('SOLVER = EULER\n\n')
f.write('KIND_TURB_MODEL = NONE\n\n')
f.write('KIND_VERIFICATION_SOLUTION= NO_VERIFICATION_SOLUTION\n\n')
f.write('MATH_PROBLEM = DIRECT\n\n')
f.write('AXISYMMETRIC= NO\n\n')
f.write('RESTART_SOL = NO\n\n')
f.write('DISCARD_INFILES= NO\n\n')
f.write('SYSTEM_MEASUREMENTS= SI\n\n')

# Freestream definition
f.write('MACH_NUMBER = ' + str(float(mach)) + '\n\n')
Expand Down Expand Up @@ -77,7 +83,7 @@ def write_SU2_cfg(tag,SU2_settings):
f.write('CFL_ADAPT = YES\n\n')
f.write('CFL_ADAPT_PARAM = ( 1.5, 0.5, 1.0, 100.0 )\n\n')
f.write('RK_ALPHA_COEFF = ( 0.66667, 0.66667, 1.000000 )\n\n')
f.write('EXT_ITER ='+str(int(iters)) +'\n\n')
f.write('INNER_ITER ='+str(int(iters)) +'\n\n')
f.write('LINEAR_SOLVER = FGMRES\n\n')
f.write('LINEAR_SOLVER_ERROR = 1E-6\n\n')
f.write('LINEAR_SOLVER_ITER = 2\n\n')
Expand Down Expand Up @@ -114,28 +120,28 @@ def write_SU2_cfg(tag,SU2_settings):

# Convergence parameters
f.write('CONV_CRITERIA = CAUCHY\n\n')
f.write('RESIDUAL_REDUCTION = 8\n\n')
f.write('RESIDUAL_MINVAL = -12\n\n')
f.write('STARTCONV_ITER = 25\n\n')
f.write('CAUCHY_ELEMS = 100\n\n')
f.write('CAUCHY_EPS = 1E-6\n\n')
f.write('CAUCHY_FUNC_FLOW = LIFT\n\n')
f.write('CONV_RESIDUAL_MINVAL = -12\n\n')
f.write('CONV_STARTITER = 25\n\n')
f.write('CONV_CAUCHY_ELEMS = 100\n\n')
f.write('CONV_CAUCHY_EPS = 1E-6\n\n')

# Input/Output
f.write('SCREEN_OUTPUT= ( LIFT, DRAG, INNER_ITER, WALL_TIME, RMS_DENSITY, RMS_ENERGY)\n\n')
f.write('HISTORY_OUTPUT= ( ITER, AERO_COEFF, RMS_RES )\n\n')
f.write('MESH_FILENAME = ' + tag + '.su2\n\n')
f.write('MESH_OUT_FILENAME = mesh_out.su2\n\n')
f.write('SOLUTION_FLOW_FILENAME = solution_flow.dat\n\n')
f.write('SOLUTION_FILENAME = solution_flow.dat\n\n')
f.write('SOLUTION_ADJ_FILENAME = solution_adj.dat\n\n')
f.write('MESH_FORMAT = SU2\n\n')
f.write('OUTPUT_FORMAT = TECPLOT\n\n')
f.write('TABULAR_FORMAT = TECPLOT\n\n')
f.write('CONV_FILENAME = ' + tag + '_history\n\n')
f.write('BREAKDOWN_FILENAME = ' + tag + '_forces_breakdown.dat\n\n')
f.write('RESTART_FLOW_FILENAME = ' + tag + '_restart_flow.dat\n\n')
f.write('RESTART_FILENAME = ' + tag + '_restart_flow.dat\n\n')
f.write('RESTART_ADJ_FILENAME = restart_adj.dat\n\n')
f.write('VOLUME_FLOW_FILENAME = ' + tag + '_flow\n\n')
f.write('VOLUME_FILENAME = ' + tag + '_flow\n\n')
f.write('VOLUME_ADJ_FILENAME = adjoint\n\n')
f.write('GRAD_OBJFUNC_FILENAME = of_grad.dat\n\n')
f.write('SURFACE_FLOW_FILENAME = ' + tag + '_surface_flow\n\n')
f.write('SURFACE_FILENAME = ' + tag + '_surface_flow\n\n')
f.write('SURFACE_ADJ_FILENAME = surface_adjoint\n\n')
f.write('WRT_SOL_FREQ = 1000\n\n')
f.write('WRT_CON_FREQ = 1\n\n')
Expand Down
2 changes: 1 addition & 1 deletion trunk/SUAVE/Methods/Aerodynamics/AVL/write_input_deck.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

## @ingroup Methods-Aerodynamics-AVL
def write_input_deck(avl_object,trim_aircraft):
""" This fucntions writes the execution steps used in the AVL call
""" This function writes the execution steps used in the AVL call
Assumptions:
None
Expand Down
5 changes: 3 additions & 2 deletions trunk/SUAVE/Optimization/Package_Setups/scipy_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#
# Created: Aug 2015, E. Botero
# Modified: Feb 2017, M. Vegh
# Mar 2020, E. Botero

# ----------------------------------------------------------------------
# Imports
Expand All @@ -17,7 +18,7 @@
# ----------------------------------------------------------------------

## @ingroup Optimization-Package_Setups
def SciPy_Solve(problem,solver='SLSQP', sense_step = 1.4901161193847656e-08, pop_size = 10 , prob_seed = None ):
def SciPy_Solve(problem,solver='SLSQP', sense_step = 1.4901161193847656e-08, tolerance = 1e-6, pop_size = 10 , prob_seed = None ):
""" This converts your SUAVE Nexus problem into a SciPy optimization problem and solves it
SciPy has many algorithms, they can be switched out by using the solver input.
Expand Down Expand Up @@ -67,7 +68,7 @@ def SciPy_Solve(problem,solver='SLSQP', sense_step = 1.4901161193847656e-08, pop

# Finalize problem statement and run
if solver=='SLSQP':
outputs = sp.optimize.fmin_slsqp(wrapper,x,f_eqcons=problem.equality_constraint,f_ieqcons=problem.inequality_constraint,bounds=bnds,iter=200, epsilon = sense_step, acc = sense_step**2)
outputs = sp.optimize.fmin_slsqp(wrapper,x,f_eqcons=problem.equality_constraint,f_ieqcons=problem.inequality_constraint,bounds=bnds,iter=200, epsilon = sense_step, acc = tolerance)
elif solver == 'differential_evolution':
outputs = sp.optimize.differential_evolution(wrapper, bounds= de_bnds, strategy='best1bin', maxiter=1000, popsize = pop_size, tol=0.01, mutation=(0.5, 1), recombination=0.7, seed=prob_seed, callback=None, disp=False, polish=True, init='latinhypercube', atol=0, updating='immediate', workers=1)
elif solver == 'particle_swarm_optimization':
Expand Down
4 changes: 2 additions & 2 deletions trunk/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ def main():
import sys

the_package = 'SUAVE'
version = '2.0.0'
date = 'February 14, 2019'
version = '2.1.0'
date = 'March 25, 2020'

if len(sys.argv) >= 2:
command = sys.argv[1]
Expand Down

0 comments on commit 93ef42a

Please sign in to comment.