Skip to content

Commit

Permalink
Merge pull request #229 from suavecode/feature-vsp_area_update
Browse files Browse the repository at this point in the history
Changes for New Versions of OpenVSP and SU2
  • Loading branch information
timdmacdo authored Mar 23, 2018
2 parents 275b463 + c1bb013 commit c56ba5c
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 33 deletions.
3 changes: 2 additions & 1 deletion trunk/SUAVE/Input_Output/OpenVSP/get_vsp_areas.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#
# Created: --- 2016, T. MacDonald
# Modified: Aug 2017, T. MacDonald
# Mar 2018, T. MacDonald

try:
import vsp_g as vsp
Expand Down Expand Up @@ -57,7 +58,7 @@ def get_vsp_areas(tag):
break
else:
vals = line.split(',')
item_tag = vals[0][:-1]
item_tag = vals[0][:]
item_w_area = float(vals[2])
if item_tag in wetted_areas:
item_w_area = wetted_areas[item_tag] + item_w_area
Expand Down
56 changes: 33 additions & 23 deletions trunk/SUAVE/Input_Output/SU2/call_SU2_CFD.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#
# Created: Oct 2016, T. MacDonald
# Modified: Jan 2017, T. MacDonald
# Mar 2018, T. MacDonald

import subprocess
from SUAVE.Core import Data
Expand All @@ -24,7 +25,7 @@ def call_SU2_CFD(tag,parallel=False,processors=1):
processors (optional) [-] The number of processors used for a parallel computation.
Outputs:
<tag>._forces_breakdown.dat This file has standard SU2 run information.
<tag>_history.dat This file has the SU2 convergence history.
CL [-]
CD [-]
Expand All @@ -40,32 +41,41 @@ def call_SU2_CFD(tag,parallel=False,processors=1):
else:
subprocess.call(['SU2_CFD',tag+'.cfg'])

f = open(tag + '_forces_breakdown.dat')
f = open(tag + '_history.dat')

SU2_results = Data()

# only the total forces have the ":"
for line in f:
if line.startswith('Total CL:'):
print 'CL:',line.split()[2]
SU2_results.coefficient_of_lift = float(line.split()[2])
elif line.startswith('Total CD:'):
print 'CD:',line.split()[2]
SU2_results.coefficient_of_drag = float(line.split()[2])
elif line.startswith('Total CMx:'):
print 'CMx:',line.split()[2]
SU2_results.moment_coefficient_x = float(line.split()[2])
elif line.startswith('Total CMy:'):
print 'CMy:',line.split()[2]
SU2_results.moment_coefficient_y = float(line.split()[2])
elif line.startswith('Total CMz:'):
print 'CMz:',line.split()[2]
SU2_results.moment_coefficient_z = float(line.split()[2])

CL = SU2_results.coefficient_of_lift
CD = SU2_results.coefficient_of_drag
lines = f.readlines()
final_state = lines[-1].split(',')

# Lift and Drag

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

SU2_results.coefficient_of_lift = CL
SU2_results.coefficient_of_drag = CD

print 'CL:',CL
print 'CD:',CD

# Moments
# Moments are currently not recorded since no
# reasonable reference length has been chosen

#CMx = float(final_state[4])
#CMy = float(final_state[5])
#CMz = float(final_state[6])

#SU2_results.moment_coefficient_x = CMx
#SU2_results.moment_coefficient_y = CMy
#SU2_results.moment_coefficient_z = CMz

#print 'CMx:',CMx
#print 'CMy:',CMy
#print 'CMz:',CMz

return CL,CD

if __name__ == '__main__':
call_SU2_CFD('cruise',parallel=True)
call_SU2_CFD('cruise',parallel=True)
18 changes: 9 additions & 9 deletions trunk/SUAVE/Input_Output/SU2/write_SU2_cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#
# Created: Oct 2016, T. MacDonald
# Modified: Jan 2017, T. MacDonald
# Mar 2018, T. MacDonald

## @ingroup Input_Output-SU2
def write_SU2_cfg(tag,SU2_settings):
Expand Down Expand Up @@ -54,7 +55,7 @@ def write_SU2_cfg(tag,SU2_settings):
f.write('REF_ORIGIN_MOMENT_X = 0.25\n\n')
f.write('REF_ORIGIN_MOMENT_Y = 0.00\n\n')
f.write('REF_ORIGIN_MOMENT_Z = 0.00\n\n')
f.write('REF_LENGTH_MOMENT = 1.0\n\n')
f.write('REF_LENGTH = 1.0\n\n')
f.write('REF_AREA = ' + str(float(ref_area)) + '\n\n')
f.write('REF_DIMENSIONALIZATION = FREESTREAM_VEL_EQ_ONE\n\n')

Expand Down Expand Up @@ -82,9 +83,8 @@ def write_SU2_cfg(tag,SU2_settings):
f.write('LINEAR_SOLVER_ITER = 2\n\n')

# Slope limiter
f.write('REF_ELEM_LENGTH = 0.1\n\n')
f.write('LIMITER_COEFF = 0.3\n\n')
f.write('SHARP_EDGES_COEFF = 3.0\n\n')
f.write('VENKAT_LIMITER_COEFF = 0.3\n\n')
f.write('ADJ_SHARP_LIMITER_COEFF = 3.0\n\n')
f.write('REF_SHARP_EDGES = 3.0\n\n')
f.write('SENS_REMOVE_SHARP = YES\n\n')

Expand All @@ -99,16 +99,16 @@ def write_SU2_cfg(tag,SU2_settings):

# Flow numerical method
f.write('CONV_NUM_METHOD_FLOW = JST\n\n')
f.write('SPATIAL_ORDER_FLOW = 2ND_ORDER\n\n')
f.write('MUSCL_FLOW = YES\n\n')
f.write('SLOPE_LIMITER_FLOW = VENKATAKRISHNAN\n\n')
f.write('AD_COEFF_FLOW = ( 0.15, 0.5, 0.02 )\n\n')
f.write('JST_SENSOR_COEFF = ( 0.5, 0.02 )\n\n')
f.write('TIME_DISCRE_FLOW = EULER_IMPLICIT\n\n')

# Adjoint-flow numerical method
f.write('CONV_NUM_METHOD_ADJFLOW = JST\n\n')
f.write('SPATIAL_ORDER_ADJFLOW = 2ND_ORDER\n\n')
f.write('MUSCL_ADJFLOW = YES\n\n')
f.write('SLOPE_LIMITER_ADJFLOW = VENKATAKRISHNAN\n\n')
f.write('AD_COEFF_ADJFLOW = ( 0.15, 0.0, 0.02 )\n\n')
f.write('ADJ_JST_SENSOR_COEFF = ( 0.0, 0.02 )\n\n')
f.write('CFL_REDUCTION_ADJFLOW = 0.5\n\n')
f.write('TIME_DISCRE_ADJFLOW = EULER_IMPLICIT\n\n')

Expand All @@ -128,7 +128,7 @@ def write_SU2_cfg(tag,SU2_settings):
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('CONV_FILENAME = history\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_ADJ_FILENAME = restart_adj.dat\n\n')
Expand Down

0 comments on commit c56ba5c

Please sign in to comment.