Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SA-BCM model introduction and cascade use-case refactoring #24

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions aero_optim/mesh/cascade_mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ def __init__(self, config: dict, datfile: str = ""):
- nodes_sp8 (int): the number of nodes to mesh the 2nd section of the blade pressure side.
- nodes_ss (int): the number of nodes to mesh the suction side (dlr_mesh set to False).
- nodes_ps (int): the number of nodes to mesh the pressure side (dlr_mesh set to False).
- cyl_vin (float): cylinder field parameter Vin.
- cyl_vout (float): cylinder field parameter Vout.
- cyl_xaxis (float): cylinder field parameter Xaxis.
- cyl_xcenter (float): cylinder field parameter Xcenter.

Note:
for the DLR configuration, the blade is split into 9 splines (clockwise from the tip):
Expand Down Expand Up @@ -69,8 +73,12 @@ def __init__(self, config: dict, datfile: str = ""):
self.nodes_sp4: int = self.config["gmsh"]["mesh"].get("nodes_sp4", 14)
self.nodes_sp7: int = self.config["gmsh"]["mesh"].get("nodes_sp7", 57)
self.nodes_sp8: int = self.config["gmsh"]["mesh"].get("nodes_sp8", 32)
self.nodes_ss: int = self.config["gmsh"]["mesh"].get("nodes_ss", 600)
self.nodes_ps: int = self.config["gmsh"]["mesh"].get("nodes_ps", 600)
self.nodes_ss: int = self.config["gmsh"]["mesh"].get("nodes_ss", 400)
self.nodes_ps: int = self.config["gmsh"]["mesh"].get("nodes_ps", 400)
self.cyl_vin: float = self.config["gmsh"]["mesh"].get("cyl_vin", 8e-4)
self.cyl_vout: float = self.config["gmsh"]["mesh"].get("cyl_vout", 5e-3)
self.cyl_xaxis: float = self.config["gmsh"]["mesh"].get("cyl_xaxis", 1.675e-2)
self.cyl_xcenter: float = self.config["gmsh"]["mesh"].get("cyl_xcenter", 8.364e-2)

def process_config(self):
logger.debug("processing config..")
Expand Down Expand Up @@ -257,7 +265,13 @@ def build_2dmesh(self):
self.build_bl(spl_list) if self.bl else 0
# Cylinder #1
f_cyl1 = self.build_cylinder_field(
9e-3, 8e-4, 5e-3, 1.675e-2, 8.364e-2, -1.171e-3, 1.9754e-2
9e-3,
self.cyl_vin,
self.cyl_vout,
self.cyl_xaxis,
self.cyl_xcenter,
-1.171e-3,
1.9754e-2
)
# Cylinder #2
f_cyl2 = self.build_cylinder_field(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
FAILURE: int = 1
SUCCESS: int = 0

WOLF: str = "/home/mschouler/bin/wolf_fix_bc"
WOLF: str = "/home/mschouler/bin/wolf_sabcm"
METRIX: str = "/home/mschouler/bin/metrix"
FEFLO: str = "/home/mschouler/bin/fefloa_margaret"
INTERPOL: str = "/home/mschouler/bin/interpol"
Expand Down Expand Up @@ -219,7 +219,8 @@ def execute_simulation(
[f"{input}.wolf", f"{input}.wolf", f"{input}.solb", f"{input}.solb", f"{input}.meshb"],
["file.wolf", "DEFAULT.wolf", "file.solb", "file.o.solb", "file.meshb"]
)
ln_filelist(["file.meshb", "file.back.meshb"], ["file.metric.meshb", "logCfl.back.meshb"])
ln_filelist(["file.meshb", "file.meshb", "file.back.meshb"],
["file.metric.meshb", "logCfl.meshb", "logCfl.back.meshb"])

# compute metric from initial condition
wolf_cmd = [WOLF, "-in", "file", "-out", "file.o", "-nproc", f"{args.nproc}", "-v", "6"]
Expand Down Expand Up @@ -266,7 +267,7 @@ def execute_simulation(
"CycleMet.meshb", "-keep-line-ids", "11,28", "-nordg",
"-back", f"{input}.back" , "-itp", "file.back.solb"]
try:
run(feflo_cmd, f"feflo.{sub_ite}.job", timeout=3.)
run(feflo_cmd, f"feflo.{sub_ite}.job", timeout=30.)
except TimeoutExpired:
print("ERROR -- feflo CycleMet subprocess timed out")
os.chdir(cwd)
Expand All @@ -292,7 +293,7 @@ def execute_simulation(
feflo_cmd = [FEFLO, "-in", "Forth", "-met", "CycleMetForth", "-out",
"Cycleadap.meshb", "-keep-line-ids", "32125,32126,1,2,3,4"]
try:
run(feflo_cmd, f"feflo.{sub_ite}.job", timeout=3.)
run(feflo_cmd, f"feflo.{sub_ite}.job", timeout=30.)
except TimeoutExpired:
print("ERROR -- feflo CycleMetForth subprocess timed out")
os.chdir(cwd)
Expand Down Expand Up @@ -538,43 +539,22 @@ def main() -> int:
print("** OP1 SIMULATION (+5 deg.) **")
print("** ------------------------ **")
sim_dir = "OP1"
adp_ite, adp_cmp = args.nite, args.cmp
op_ite = 0
# restart from ADP adapted mesh and previous complexity
while adp_ite - op_ite >= 1:
shutil.rmtree(sim_dir, ignore_errors=True)
os.mkdir(sim_dir)
cp_filelist([f"{input}.wolf"], [f"{sim_dir}"])
cp_filelist([f"ADP/adap_{adp_ite - op_ite}/final.meshb"], [f"{sim_dir}/{input}.meshb"])
cp_filelist([f"ADP/{input}.back.meshb", f"ADP/{input}.back.solb"], [f"{sim_dir}"] * 2)
cv_tgt_op = cv_tgt[adp_ite - (op_ite + 1):]
args.cmp = adp_cmp * 2**(adp_ite - (op_ite + 1))
args.nite = op_ite + 1
os.chdir(sim_dir)
# update input velocity
cos = math.cos((43 + 5) / 180 * math.pi)
sin = math.sin((43 + 5) / 180 * math.pi)
u = 199.5 * cos
v = 199.5 * sin
# update input file
sim_args = {
"PhysicalState": {"inplace": False, "param": [f" 0.1840 {u} {v} 0. 14408 1.7039e-5"]},
"BCInletVelocityDirection": {"inplace": False, "param": [f"{cos} {sin} 0."]}
}
sed_in_file(f"{input}.wolf", sim_args)
exit_status = robust_execution(
args, t0, cv_tgt_op,
default_res_tgt=1e-2,
ite_restart=1,
subite_restart=2,
preprocess=False
)
if exit_status == FAILURE:
print(f"ERROR -- adaptation failed after {time.time() - t0} seconds & cmp {args.cmp}\n")
op_ite += 1
os.chdir(cwd)
else:
break
shutil.rmtree(sim_dir, ignore_errors=True)
os.mkdir(sim_dir)
cp_filelist([f"{input}.wolf", f"{input}.mesh"], [sim_dir] * 2)
os.chdir(sim_dir)
# update input velocity
cos = math.cos((43 + 5) / 180 * math.pi)
sin = math.sin((43 + 5) / 180 * math.pi)
u = 199.5 * cos
v = 199.5 * sin
# update input file
sim_args = {
"PhysicalState": {"inplace": False, "param": [f" 0.1840 {u} {v} 0. 14408 1.7039e-5"]},
"BCInletVelocityDirection": {"inplace": False, "param": [f"{cos} {sin} 0."]}
}
sed_in_file(f"{input}.wolf", sim_args)
exit_status = robust_execution(args, t0, cv_tgt, ite_restart=3, subite_restart=5)
if exit_status == FAILURE:
print(f"ERROR -- adaptation failed after {time.time() - t0} seconds")
return FAILURE
Expand All @@ -583,38 +563,21 @@ def main() -> int:
print("** OP2 SIMULATION (-5 deg.) **")
print("** ------------------------ **")
sim_dir = "OP2"
op_ite = 0
# restart from ADP adapted mesh and previous complexity
while adp_ite - op_ite >= 1:
shutil.rmtree(sim_dir, ignore_errors=True)
os.mkdir(sim_dir)
cp_filelist([f"{input}.wolf"], [f"{sim_dir}"])
cp_filelist([f"ADP/adap_{adp_ite - op_ite}/final.meshb"], [f"{sim_dir}/{input}.meshb"])
cp_filelist([f"ADP/{input}.back.meshb", f"ADP/{input}.back.solb"], [f"{sim_dir}"] * 2)
cv_tgt_op = cv_tgt[adp_ite - (op_ite + 1):]
args.cmp = adp_cmp * 2**(adp_ite - (op_ite + 1))
args.nite = op_ite + 1
os.chdir(sim_dir)
# update input velocity
cos = math.cos((43 - 5) / 180 * math.pi)
sin = math.sin((43 - 5) / 180 * math.pi)
u = 199.5 * cos
v = 199.5 * sin
# update input file
sim_args = {
"PhysicalState": {"inplace": False, "param": [f" 0.1840 {u} {v} 0. 14408 1.7039e-5"]},
"BCInletVelocityDirection": {"inplace": False, "param": [f"{cos} {sin} 0."]}
}
sed_in_file(f"{input}.wolf", sim_args)
exit_status = robust_execution(
args, t0, cv_tgt_op, ite_restart=1, subite_restart=2, preprocess=False
)
if exit_status == FAILURE:
print(f"ERROR -- adaptation failed after {time.time() - t0} seconds & cmp {args.cmp}\n")
op_ite += 1
os.chdir(cwd)
else:
break
os.mkdir(sim_dir)
cp_filelist([f"{input}.wolf", f"{input}.mesh"], [sim_dir] * 2)
os.chdir(sim_dir)
# update input velocity
cos = math.cos((43 - 5) / 180 * math.pi)
sin = math.sin((43 - 5) / 180 * math.pi)
u = 199.5 * cos
v = 199.5 * sin
# update input file
sim_args = {
"PhysicalState": {"inplace": False, "param": [f" 0.1840 {u} {v} 0. 14408 1.7039e-5"]},
"BCInletVelocityDirection": {"inplace": False, "param": [f"{cos} {sin} 0."]}
}
sed_in_file(f"{input}.wolf", sim_args)
exit_status = robust_execution(args, t0, cv_tgt, ite_restart=3, subite_restart=5)
if exit_status == FAILURE:
print(f"ERROR -- adaptation failed after {time.time() - t0} seconds")
return FAILURE
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"study": {
"study_type": "cascade",
"file": "blade.dat",
"file": "../data/lrn_cascade.dat",
"outdir": "output"
},
"gmsh": {
Expand Down Expand Up @@ -29,6 +29,6 @@
"turbocoef.dat": ["LossCoef"],
"wall.dat": ["x", "y", "Mis"]
},
"exec_cmd": "python3 /home/mschouler/Documents/Sorbonne/aero-optim/examples/cascade/adap_robust.py -in @.mesh -cmp 2000 -nproc 8 -nite 4 -smax 10"
"exec_cmd": "python3 /home/mschouler/Documents/Sorbonne/aero-optim/examples/LRN-CASCADE/cascade_adap/adap_robust.py -in @.mesh -cmp 2000 -nproc 8 -nite 4 -smax 10"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,15 @@
SteadyFlow
NavierStokes
SpalartAllmarasTurbulenceModel
SABCMModel
SANegativeModel

FreeStreamNuSA
1.5e-2

TurbulentIntensity
0.5

Gamma
1.400

Expand Down Expand Up @@ -113,7 +120,7 @@ StatisticalResidual
PrintFrequency
20
SaveFrequency
100
1000
SaveLight

AeroReferenceLength
Expand Down Expand Up @@ -184,4 +191,4 @@ SteadyFeatureBasedAdaptation
RANSHessianBdryCorrection
4.

# -------------------
# -------------------