Skip to content

Commit

Permalink
refactor XFoil to suppress window generation always
Browse files Browse the repository at this point in the history
  • Loading branch information
peterdsharpe committed Mar 4, 2024
1 parent a5faf4b commit d6170fa
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions aerosandbox/aerodynamics/aero_2D/xfoil.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ def __repr__(self):
return f"XFoil(airfoil={self.airfoil}, Re={self.Re}, mach={self.mach}, n_crit={self.n_crit})"

def _default_keystrokes(self,
airfoil_filename: str,
output_filename: str,
) -> List[str]:
"""
Expand All @@ -179,6 +180,11 @@ def _default_keystrokes(self,
"",
]

# Load the airfoil
run_file_contents += [
f"load {airfoil_filename}",
]

if self.xfoil_repanel:
run_file_contents += [
"ppar",
Expand Down Expand Up @@ -278,7 +284,10 @@ def _run_xfoil(self,
self.airfoil.write_dat(directory / airfoil_file)

# Handle the keystroke file
keystrokes = self._default_keystrokes(output_filename=output_filename)
keystrokes = self._default_keystrokes(
airfoil_filename=airfoil_file,
output_filename=output_filename
)
keystrokes += [run_command]
keystrokes += [
"pacc", # End polar accumulation
Expand All @@ -295,9 +304,8 @@ def _run_xfoil(self,
### Execute
try:
# command = f'{self.xfoil_command} {airfoil_file}' # Old syntax; try this if calls are not working
command = [self.xfoil_command, airfoil_file]
proc = subprocess.Popen(
command,
self.xfoil_command,
cwd=directory,
stdin=subprocess.PIPE,
stdout=None if self.verbose else subprocess.DEVNULL,
Expand Down Expand Up @@ -337,7 +345,7 @@ def _run_xfoil(self,
"your XFoil run at a less-aggressive (alpha closer to 0, higher Re) operating point.")
elif e.returncode == 1:
raise self.XFoilError(
f"Command '{command}' returned non-zero exit status 1.\n"
f"Command '{self.xfoil_command}' returned non-zero exit status 1.\n"
f"This is likely because AeroSandbox does not see XFoil on PATH with the given command.\n"
f"Check the logs (`asb.XFoil(..., verbose=True)`) to verify that this is the case, and if so,\n"
f"provide the correct path to the XFoil executable in the asb.XFoil constructor via `xfoil_command=`."
Expand Down

0 comments on commit d6170fa

Please sign in to comment.