Skip to content

Commit

Permalink
ThermoData branch (#294)
Browse files Browse the repository at this point in the history
* ThermoData branch

Turboprop and turbofan exit condition calculation module added


Co-authored-by: Francesco-Marcucci <[email protected]>
  • Loading branch information
GBenedett and Francesco-Marcucci authored Apr 15, 2024
1 parent b48fda8 commit f1ee8de
Show file tree
Hide file tree
Showing 18 changed files with 2,015 additions and 7 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ warning: : The module does not work completely as expected. It is not a bug, but
- [Optimisation](ceasiompy/Optimisation/README.md) :x:
- [SMTrain](ceasiompy/SMTrain/README.md) :x:
- [SMUse](ceasiompy/SMUse/README.md) :x:
- [ThermoData](ceasiompy/ThermoData/README.md) :heavy_check_mark:
<img align="right" height="80" src="documents/logos/CEASIOMpy_banner_geometry.png">
Expand Down
2 changes: 1 addition & 1 deletion ceasiompy/CPACS2GMSH/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Multiple options are available with `CPACS2GMSH`, you can see these options if y

General options:

* `Display mesh with GMSHl : False`
* `Display mesh with GMSH : False`
Open the gmsh GUI after the generation of the surface mesh (2D) and the domain mesh (3D). This option is usefully to control the quality of the automated generated mesh or make extra operation with gmsh GUI.

Domain:
Expand Down
13 changes: 13 additions & 0 deletions ceasiompy/SU2Run/__specs__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
SU2_TARGET_CL_XPATH,
SU2_UPDATE_WETTED_AREA_XPATH,
SU2MESH_XPATH,
SU2_CONFIG_RANS_XPATH,
)
from ceasiompy.utils.moduleinterfaces import CPACSInOut

Expand Down Expand Up @@ -203,6 +204,18 @@
gui_group="CPU",
)

cpacs_inout.add_input(
var_name="RANS calculation",
var_type=list,
default_value=["Euler", "RANS"],
unit="1",
descr="Running an Euler or a RANS calculation",
xpath=SU2_CONFIG_RANS_XPATH,
gui=True,
gui_name="Euler or RANS simulation",
gui_group="SU2 Parameters",
)

cpacs_inout.add_input(
var_name="max_iter",
var_type=int,
Expand Down
198 changes: 198 additions & 0 deletions ceasiompy/SU2Run/files/config_template_rans.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,198 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% SU2 configuration file %
% Case description: VKI turbine %
% Author: Francisco Palacios, Thomas D. Economon %
% Institution: Stanford University %
% Date: Feb 18th, 2013 %
% File Version 8.0.0 "Harrier" %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% ------------- DIRECT, ADJOINT, AND LINEARIZED PROBLEM DEFINITION ------------%
%
SOLVER= RANS
%
KIND_TURB_MODEL= SA
%
MATH_PROBLEM= DIRECT
%
RESTART_SOL= NO
%
SYSTEM_MEASUREMENTS= SI

% -------------------- COMPRESSIBLE FREE-STREAM DEFINITION --------------------%
%
MACH_NUMBER= 0.3
%
AOA= 0.0
%
FREESTREAM_PRESSURE= 1.013E5
%
FREESTREAM_OPTION= DENSITY_FS
%
FREESTREAM_DENSITY = 1.255
%
FREESTREAM_TEMPERATURE =288.15
%
REYNOLDS_NUMBER= 4E6
%
REYNOLDS_LENGTH= 1.0

% ---------------------- REFERENCE VALUE DEFINITION ---------------------------%
%
REF_ORIGIN_MOMENT_X = 0.00
%
REF_ORIGIN_MOMENT_Y = 0.00
%
REF_ORIGIN_MOMENT_Z = 0.00
%
REF_LENGTH= 45.0
%
REF_AREA= 1
% Compressible flow non-dimensionalization (DIMENSIONAL, FREESTREAM_PRESS_EQ_ONE,
% FREESTREAM_VEL_EQ_MACH, FREESTREAM_VEL_EQ_ONE)
REF_DIMENSIONALIZATION= FREESTREAM_PRESS_EQ_ONE
%
% ----------------------- BOUNDARY CONDITION DEFINITION -----------------------%
%
MARKER_HEATFLUX = (S4CreatedbyGmsh, 0.0)
%
MARKER_FAR= (S3Farfield)
%
%MARKER_SYM =()
%
% ------------------------ SURFACES IDENTIFICATION ----------------------------%
%
% Marker(s) of the surface to be plotted or designed
MARKER_PLOTTING= (S4CreatedbyGmsh)
%
% Marker(s) of the surface where the functional (Cd, Cl, etc.) will be evaluated
MARKER_MONITORING= (S4CreatedbyGmsh)

% ------------- COMMON PARAMETERS DEFINING THE NUMERICAL METHOD ---------------%
%
NUM_METHOD_GRAD= GREEN_GAUSS
%
CFL_NUMBER= 1
%
CFL_ADAPT= NO
%
CFL_ADAPT_PARAM= ( 0.5, 1, 1.0, 100.0 )
%
ITER = 5000

% Objective function in gradient evaluation (DRAG, LIFT, SIDEFORCE, MOMENT_X,
% MOMENT_Y, MOMENT_Z, EFFICIENCY, BUFFET,
% EQUIVALENT_AREA, NEARFIELD_PRESSURE,
% FORCE_X, FORCE_Y, FORCE_Z, THRUST,
% TORQUE, TOTAL_HEATFLUX,
% MAXIMUM_HEATFLUX, INVERSE_DESIGN_PRESSURE,
% INVERSE_DESIGN_HEATFLUX, SURFACE_TOTAL_PRESSURE,
% SURFACE_MASSFLOW, SURFACE_STATIC_PRESSURE, SURFACE_MACH)
% For a weighted sum of objectives: separate by commas, add OBJECTIVE_WEIGHT and MARKER_MONITORING in matching order.
OBJECTIVE_FUNCTION= DRAG

% ------------------------ LINEAR SOLVER DEFINITION ---------------------------%
% Linear solver or smoother for implicit formulations:
% BCGSTAB, FGMRES, RESTARTED_FGMRES, CONJUGATE_GRADIENT (self-adjoint problems only), SMOOTHER.
LINEAR_SOLVER= FGMRES
%
% Preconditioner of the Krylov linear solver or type of smoother (ILU, LU_SGS, LINELET, JACOBI)
LINEAR_SOLVER_PREC= ILU
%
% Minimum error of the linear solver for implicit formulations
LINEAR_SOLVER_ERROR= 1E-12
%
% Max number of iterations of the linear solver for the implicit formulation
LINEAR_SOLVER_ITER= 3
%
% Number of elements to apply the criteria
CONV_CAUCHY_ELEMS= 1000
%
% Epsilon to control the series convergence
CONV_CAUCHY_EPS= 1E-10
% -------------------- FLOW NUMERICAL METHOD DEFINITION -----------------------%
% Convective numerical method (JST, LAX-FRIEDRICH, CUSP, ROE, AUSM, AUSMPLUSUP,
% AUSMPLUSUP2, HLLC, TURKEL_PREC, MSW, FDS, SLAU, SLAU2)
CONV_NUM_METHOD_FLOW= JST
%
% Time discretization (RUNGE-KUTTA_EXPLICIT, EULER_IMPLICIT, EULER_EXPLICIT)
TIME_DISCRE_FLOW= EULER_IMPLICIT
%
% -------------------- TURBULENT NUMERICAL METHOD DEFINITION ------------------%
% Convective numerical method (SCALAR_UPWIND)
CONV_NUM_METHOD_TURB= SCALAR_UPWIND
%
% Monotonic Upwind Scheme for Conservation Laws (TVD) in the turbulence equations.
% Required for 2nd order upwind schemes (NO, YES)
MUSCL_TURB= NO
%
% Slope limiter (NONE, VENKATAKRISHNAN, VENKATAKRISHNAN_WANG,
% BARTH_JESPERSEN, VAN_ALBADA_EDGE)
SLOPE_LIMITER_TURB= VENKATAKRISHNAN
%
% Time discretization (EULER_IMPLICIT)
TIME_DISCRE_TURB= EULER_IMPLICIT
% -------------------------- MULTIGRID PARAMETERS -----------------------------%
%
% Multi-Grid Levels (0 = no multi-grid)
MGLEVEL = 3
%
% Multi-grid cycle (V_CYCLE, W_CYCLE, FULLMG_CYCLE)
MGCYCLE = W_CYCLE
%
% Multi-Grid PreSmoothing Level
MG_PRE_SMOOTH = ( 1.0, 2.0, 3.0, 3.0 )
%
% Multi-Grid PostSmoothing Level
MG_POST_SMOOTH = ( 0.0, 0.0, 0.0, 0.0 )
%
% Jacobi implicit smoothing of the correction
MG_CORRECTION_SMOOTH = ( 0.0, 0.0, 0.0, 0.0 )
%
% Damping factor for the residual restriction
MG_DAMP_RESTRICTION = 0.9
%
% Damping factor for the correction prolongation
MG_DAMP_PROLONGATION = 0.9
% --------------------------- CONVERGENCE PARAMETERS --------------------------%
%
% Min value of the residual (log10 of the residual)
CONV_RESIDUAL_MINVAL= -12
%
% Start convergence criteria at iteration number
CONV_STARTITER= 10
%

% ------------------------- INPUT/OUTPUT INFORMATION --------------------------%
%
MESH_FILENAME= labair_penta.su2
%
MESH_FORMAT= SU2
%
MESH_OUT_FILENAME= mesh_out.su2
%
SOLUTION_FILENAME= solution_flow.dat
%
HISTORY_OUTPUT = (INNER_ITER, RMS_RES, AERO_COEFF)
%
TABULAR_FORMAT= CSV
%
CONV_FILENAME= history
%
RESTART_FILENAME= restart_flow.dat
%
RESTART_ADJ_FILENAME= restart_adj.dat
%
VOLUME_FILENAME= flow
%
SURFACE_FILENAME= surface_flow
%
OUTPUT_WRT_FREQ= 100
%
BREAKDOWN_FILENAME = forces_breakdown_def.dat
%
WRT_FORCES_BREAKDOWN = YES
%
SCREEN_OUTPUT= (INNER_ITER, RMS_DENSITY, RMS_ENERGY, LIFT, DRAG)
35 changes: 34 additions & 1 deletion ceasiompy/SU2Run/func/su2config.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@
SU2_ROTATION_RATE_XPATH,
SU2_TARGET_CL_XPATH,
SU2MESH_XPATH,
ENGINE_TYPE_XPATH,
ENGINE_BC,
)
from ceasiompy.utils.configfiles import ConfigFile
from cpacspy.cpacsfunctions import (
Expand Down Expand Up @@ -294,6 +296,34 @@ def add_actuator_disk(cfg, cpacs, case_dir_path, actuator_disk_file, mesh_marker
f.close()


# adding the results of ThermoData to the config file of su2


def add_thermodata(cfg, cpacs, alt, case_nb, alt_list):

if cpacs.tixi.checkElement(ENGINE_TYPE_XPATH):
log.info("adding engine BC to the SU2 config file")
engine_type = get_value(cpacs.tixi, ENGINE_TYPE_XPATH)
log.info(f"engine type {engine_type}")
alt = alt_list[case_nb]
Atm = Atmosphere(alt)
tot_temp_in = Atm.temperature[0]
tot_pressure_in = Atm.pressure[0]
if len(alt_list) > 1:
tot_temp_out = get_value(cpacs.tixi, ENGINE_BC + "/temperatureOutlet").split(";")
tot_pressure_out = get_value(cpacs.tixi, ENGINE_BC + "/pressureOutlet").split(";")
tot_temp_out = tot_temp_out[case_nb]
tot_pressure_out = tot_pressure_out[case_nb]
else:
tot_temp_out = get_value(cpacs.tixi, ENGINE_BC + "/temperatureOutlet")
tot_pressure_out = get_value(cpacs.tixi, ENGINE_BC + "/pressureOutlet")
cfg["INLET_TYPE"] = "TOTAL_CONDITIONS"
cfg["MARKER_INLET"] = (
f"(INLET_ENGINE, {tot_temp_in}, {tot_pressure_in}, {1},{0},{0}, "
f"OUTLET_ENGINE,{tot_temp_out},{tot_pressure_out}, {1},{0},{0})"
)


def generate_su2_cfd_config(cpacs_path, cpacs_out_path, wkdir):
"""Function to create SU2 config file.
Expand Down Expand Up @@ -341,7 +371,7 @@ def generate_su2_cfd_config(cpacs_path, cpacs_out_path, wkdir):

if aeromap_list:
aeromap_default = aeromap_list[0]
log.info(f'The aeromap is {aeromap_default}')
log.info(f"The aeromap is {aeromap_default}")

aeromap_uid = get_value_or_default(cpacs.tixi, SU2_AEROMAP_UID_XPATH, aeromap_default)

Expand Down Expand Up @@ -448,6 +478,7 @@ def generate_su2_cfd_config(cpacs_path, cpacs_out_path, wkdir):
cfg["HISTORY_OUTPUT"] = "(INNER_ITER, RMS_RES, AERO_COEFF)"

# Parameters which will vary for the different cases (alt,mach,aoa,aos)

for case_nb in range(len(alt_list)):
cfg["MESH_FILENAME"] = str(su2_mesh)

Expand All @@ -470,6 +501,8 @@ def generate_su2_cfd_config(cpacs_path, cpacs_out_path, wkdir):
f"_aoa{round(aoa, 1)}_aos{round(aos, 1)}"
)

add_thermodata(cfg, cpacs, alt, case_nb, alt_list)

case_dir_path = Path(wkdir, case_dir_name)
if not case_dir_path.exists():
case_dir_path.mkdir()
Expand Down
Loading

0 comments on commit f1ee8de

Please sign in to comment.