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

Update mach examples #100

Merged
merged 5 commits into from
May 16, 2022
Merged
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
25 changes: 25 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,28 @@ tests/input_files/*.xyz

# n2s that might be generated under examples
examples/**/*.html

# n2s that are generated under tests for the documentation
tests/**/*.html

# FFD files for adflow examples
examples/aero_only/mach_tutorial_wing/adflow/*.xyz
examples/aerostructural/mach_tutorial_wing/adflow_meld_tacs/*.xyz

# DAFoam input files
tests/input_files/dafoam*

# DAFoam test outputs
tests/regression_tests/0
tests/regression_tests/constant
tests/regression_tests/FFD
tests/regression_tests/system
tests/integration_tests/0
tests/integration_tests/constant
tests/integration_tests/FFD
tests/integration_tests/system
tests/0
tests/constant
tests/FFD
tests/system

2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ paramerized
and these input files. They can be obtained by running `get-input-files.sh`
```
wingbox.bdf
wing_vol_L1.cgns
wing_vol_L2.cgns
wing_vol_L3.cgns
ffd.xyz
```
Expand Down
50 changes: 0 additions & 50 deletions examples/aero_only/mach_tutorial_wing/adflow/ffd.xyz

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,23 +1,27 @@
from mpi4py import MPI
import argparse

import openmdao.api as om
from mphys.multipoint import Multipoint
from mphys.scenario_aerodynamic import ScenarioAerodynamic
from adflow.mphys import ADflowBuilder
from baseclasses import AeroProblem
from mphys.scenario_aerodynamic import ScenarioAerodynamic

parser = argparse.ArgumentParser()
parser.add_argument("--level", type=str, default="L1")
args = parser.parse_args()

class Top(Multipoint):
def setup(self):

aero_options = {
# I/O Parameters
"gridFile": "wing_vol.cgns",
"gridFile": f"wing_vol_{args.level}.cgns",
"outputDirectory": ".",
"monitorvariables": ["resrho", "cl", "cd"],
"writeTecplotSurfaceSolution": True,
# Physics Parameters
"equationType": "RANS",
"liftindex": 3, # z is the lift direction
# Solver Parameters
"smoother": "DADI",
"CFL": 0.5,
Expand Down Expand Up @@ -90,7 +94,7 @@ def configure(self):
prob.model.list_outputs(units=True)

# prob.model.list_outputs()
if MPI.COMM_WORLD.rank == 0:
if prob.model.comm.rank == 0:
print("Scenario 0")
print("cl =", prob["cruise.aero_post.cl"])
print("cd =", prob["cruise.aero_post.cd"])
27 changes: 16 additions & 11 deletions examples/aero_only/mach_tutorial_wing/adflow/mphys_aero_opt.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import argparse
import numpy as np
from mpi4py import MPI

import openmdao.api as om
from mphys.multipoint import Multipoint
Expand All @@ -8,10 +8,9 @@
from baseclasses import AeroProblem
from pygeo.mphys import OM_DVGEOCOMP

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--task", default="run")
parser.add_argument("--level", type=str, default="L1")
args = parser.parse_args()


Expand All @@ -23,14 +22,15 @@ def setup(self):
################################################################################
aero_options = {
# I/O Parameters
"gridFile": "wing_vol.cgns",
"gridFile": f"wing_vol_{args.level}.cgns",
"outputDirectory": ".",
"monitorvariables": ["resrho", "resturb", "cl", "cd"],
"writeTecplotSurfaceSolution": False,
# 'writevolumesolution':False,
# 'writesurfacesolution':False,
# Physics Parameters
"equationType": "RANS",
"liftindex": 3, # z is the lift direction
# Solver Parameters
"smoother": "DADI",
"CFL": 1.5,
Expand Down Expand Up @@ -118,13 +118,19 @@ def configure(self):
# Set up global design variables
def twist(val, geo):
for i in range(1, nRefAxPts):
geo.rot_z["wing"].coef[i] = val[i - 1]
geo.rot_y["wing"].coef[i] = val[i - 1]

self.geometry.nom_addGeoDVGlobal(dvName="twist", value=np.array([0] * nTwist), func=twist)
nLocal = self.geometry.nom_addGeoDVLocal(dvName="thickness")

leList = [[0.01, 0, 0.001], [7.51, 0, 13.99]]
teList = [[4.99, 0, 0.001], [8.99, 0, 13.99]]
nLocal = self.geometry.nom_addGeoDVLocal(dvName="thickness", axis="z")

if args.level == "L3":
# we need to offset the projected points a bit further in the wing because this mesh is too coarse
leList = [[0.1, 0.001, 0.0], [7.6, 13.8, 0.0]]
teList = [[4.8, 0.001, 0.0], [8.8, 13.8, 0.0]]
else:
# L1 and L2 meshes can work with the more accurate coordinates
leList = [[0.01, 0.001, 0.0], [7.51, 13.99, 0.0]]
teList = [[4.99, 0.001, 0.0], [8.99, 13.99, 0.0]]
self.geometry.nom_addThicknessConstraints2D("thickcon", leList, teList, nSpan=10, nChord=10)
self.geometry.nom_addVolumeConstraint("volcon", leList, teList, nSpan=20, nChord=20)
self.geometry.nom_add_LETEConstraint(
Expand Down Expand Up @@ -201,8 +207,7 @@ def twist(val, geo):
prob.model.list_inputs(units=True)
prob.model.list_outputs(units=True)

# prob.model.list_outputs()
if MPI.COMM_WORLD.rank == 0:
if prob.model.comm.rank == 0:
print("Scenario 0")
print("cl =", prob["cruise.aero_post.cl"])
print("cd =", prob["cruise.aero_post.cd"])
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import argparse
import numpy as np
from mpi4py import MPI

import openmdao.api as om
from mphys.multipoint import Multipoint
Expand All @@ -8,10 +8,10 @@
from baseclasses import AeroProblem
from pygeo.mphys import OM_DVGEOCOMP

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--task", default="run")
parser.add_argument("--level", type=str, default="L1")
args = parser.parse_args()


Expand All @@ -23,14 +23,15 @@ def setup(self):
################################################################################
aero_options = {
# I/O Parameters
"gridFile": "wing_vol.cgns",
"gridFile": f"wing_vol_{args.level}.cgns",
"outputDirectory": ".",
"monitorvariables": ["resrho", "resturb", "cl", "cd"],
"writeTecplotSurfaceSolution": False,
# 'writevolumesolution':False,
# 'writesurfacesolution':False,
# Physics Parameters
"equationType": "RANS",
"liftindex": 3, # z is the lift direction
# Solver Parameters
"smoother": "DADI",
"CFL": 1.5,
Expand Down Expand Up @@ -129,7 +130,7 @@ def configure(self):
# Set up global design variables
def twist(val, geo):
for i in range(1, nRefAxPts):
geo.rot_z["wing"].coef[i] = val[i - 1]
geo.rot_y["wing"].coef[i] = val[i - 1]

self.geometry.nom_addGeoDVGlobal(dvName="twist", value=np.array([0] * nTwist), func=twist)

Expand Down Expand Up @@ -200,7 +201,7 @@ def twist(val, geo):
prob.model.list_outputs(units=True)

# prob.model.list_outputs()
if MPI.COMM_WORLD.rank == 0:
if prob.model.comm.rank == 0:
print("Cruise 0")
print("cl =", prob["cruise0.aero_post.cl"])
print("cd =", prob["cruise0.aero_post.cd"])
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
from mpi4py import MPI
import argparse

import openmdao.api as om
from mphys.multipoint import MultipointParallel
from mphys.scenario_aerodynamic import ScenarioAerodynamic
from adflow.mphys import ADflowBuilder
from baseclasses import AeroProblem

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--task", default="run")
parser.add_argument("--level", type=str, default="L1")
args = parser.parse_args()


Expand All @@ -21,15 +21,15 @@ def setup(self):
################################################################################
aero_options = {
# I/O Parameters
# "gridFile": "wing_vol_coarse.cgns",
"gridFile": "wing_vol.cgns",
"gridFile": f"wing_vol_{args.level}.cgns",
"outputDirectory": ".",
"monitorvariables": ["resrho", "resturb", "cl", "cd"],
"writeTecplotSurfaceSolution": False,
# 'writevolumesolution':False,
# 'writesurfacesolution':False,
# Physics Parameters
"equationType": "RANS",
"liftindex": 3, # z is the lift direction
# Solver Parameters
"smoother": "DADI",
"CFL": 1.5,
Expand Down Expand Up @@ -220,7 +220,7 @@ def configure(self):
cl1 = prob.get_val("mp.cruise1.aero_post.cl", get_remote=True)
cd1 = prob.get_val("mp.cruise1.aero_post.cd", get_remote=True)

if MPI.COMM_WORLD.rank == 0:
if prob.model.comm.rank == 0:
print("Cruise 0")
print("cl =", cl0)
print("cd =", cd1)
Expand Down
5 changes: 5 additions & 0 deletions examples/aero_only/mach_tutorial_wing/adflow/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
To obtain the CFD grids and the FFD box required for these examples:

1. Go to mphys/tests/input_files
2. Run the get-input-files.sh script. This will download and extract the input file archive provided by the University of Michigan.
3. Copy the wing_vol_L*.cgns and ffd.xyz files to this directory.
Original file line number Diff line number Diff line change
@@ -1,30 +1,23 @@
import numpy as np
import argparse
from mpi4py import MPI

import openmdao.api as om

from mphys import Multipoint
from mphys.scenario_aerostructural import ScenarioAeroStructural


from adflow.mphys import ADflowBuilder
from baseclasses import AeroProblem
from tacs.mphys import TacsBuilder
from mphys.solver_builders.mphys_meld import MeldBuilder

# TODO RLT needs to be updated with the new tacs wrapper
# from rlt.mphys import RltBuilder

from baseclasses import AeroProblem

import tacs_setup

# set these for convenience
comm = MPI.COMM_WORLD
rank = comm.rank

parser = argparse.ArgumentParser()
parser.add_argument("--xfer", default="meld", choices=["meld", "rlt"])
parser.add_argument("--level", type=str, default="L1")
args = parser.parse_args()

if args.xfer == "meld":
Expand All @@ -41,14 +34,15 @@ def setup(self):
################################################################################
aero_options = {
# I/O Parameters
"gridFile": "wing_vol.cgns",
"gridFile": f"wing_vol_{args.level}.cgns",
"outputDirectory": ".",
"monitorvariables": ["resrho", "resturb", "cl", "cd"],
"writeTecplotSurfaceSolution": False,
# 'writevolumesolution':False,
# 'writesurfacesolution':False,
# Physics Parameters
"equationType": "RANS",
"liftindex": 3, # z is the lift direction
# Solver Parameters
"smoother": "DADI",
"CFL": 1.5,
Expand Down Expand Up @@ -97,7 +91,7 @@ def setup(self):
################################################################################

if args.xfer == "meld":
isym = 1
isym = 1 # y-symmetry
ldxfer_builder = MeldBuilder(aero_builder, struct_builder, isym=isym)
ldxfer_builder.initialize(self.comm)
else:
Expand Down Expand Up @@ -193,7 +187,7 @@ def configure(self):

prob.model.list_outputs()

if MPI.COMM_WORLD.rank == 0:
if prob.model.comm.rank == 0:
print("Cruise")
print("cl =", prob["cruise.aero_post.cl"])
print("cd =", prob["cruise.aero_post.cd"])
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
To obtain the CFD grids and the FFD box required for these examples:

1. Go to mphys/tests/input_files
2. Run the get-input-files.sh script. This will download and extract the input file archive provided by the University of Michigan.
3. Copy the wing_vol_L*.cgns and wingbox.bdf files to this directory.
Loading