Skip to content

Commit

Permalink
Merge pull request #86 from twiinIT/connect_pythermo
Browse files Browse the repository at this point in the history
Use `pythermo` gas models
  • Loading branch information
adriendelsalle authored Feb 20, 2023
2 parents b033cb6 + a5bdf9e commit a0a57ae
Show file tree
Hide file tree
Showing 20 changed files with 125 additions and 331 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ repos:
hooks:
- id: isort
exclude: tests/data
- repo: https://gitlab.com/pycqa/flake8
- repo: https://github.com/PyCQA/flake8
rev: 3.9.2
hooks:
- id: flake8
Expand Down
3 changes: 2 additions & 1 deletion HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# History

## 0.2.0 (2023-01-10)
## 0.2.0 (2023-02-20)

### Features

- Add new system `Atmosphere` and `TurbofanWithAtm` to ease computing of ambient conditions (from altitude, Mach and delta tamb)
- Use `pythermo` for gas modeling

### Code quality & packaging

Expand Down
5 changes: 4 additions & 1 deletion docs/build_doc.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os
from pathlib import Path
import shutil
from pathlib import Path

CWD = Path.cwd()
SOURCEDIR = "source"
Expand All @@ -11,15 +11,18 @@


def main():
"""Build documentation."""
build_documentation()
copy_notebook_resources()


def build_documentation():
"""Build documentation using Sphinx."""
return os.system("sphinx-build -b html -d _build/doctrees ./source _build")


def copy_notebook_resources():
"""Copy notebook from package to the documentation folders."""
for resource in RESOURCES:
source_path = CWD / SOURCEDIR / NOTEBOOK_FOLDER / resource
target_path = CWD / BUILDDIR / NOTEBOOK_FOLDER / resource
Expand Down
2 changes: 1 addition & 1 deletion docs/source/user_guide/notebooks/turbofan.nblink
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
"extra-media": [
"../../../../pyturbo/notebooks/textures"
]
}
}
1 change: 1 addition & 0 deletions environment-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ dependencies:
- pyoccad
- numpy
- ambiance
- pythermo
- pythreejs
- pytest
- pre-commit
Expand Down
1 change: 1 addition & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ dependencies:
- numpy
- ambiance
- pythonocc-core
- pythermo
2 changes: 1 addition & 1 deletion pyturbo/notebooks/turbofan.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@
"source": [
"### off-design computation after design\n",
"\n",
"Fuel comsumption for a given altitude/mach/dtamb and thrust. "
"Fuel consumption for a given altitude/mach/dtamb and thrust. "
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion pyturbo/systems/combustor/combustor_aero.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,5 @@ def compute(self):
self.fl_out.W = self.fl_in.W + self.fuel_W

h_out = self.gas.h(self.fl_in.Tt) + self.fuel_W / self.fl_out.W * self.fhv * self.eff
self.Tcomb = self.gas.t_from_h(h_out)
self.Tcomb = self.gas.t_f_h(h_out, tol=1e-6)
self.fl_out.Tt = self.Tcomb
2 changes: 1 addition & 1 deletion pyturbo/systems/compressor/compressor_aero.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def compute(self):

delta_h = self.sh_in.power / self.fl_in.W
h = self.gas.h(self.fl_in.Tt) + delta_h
self.fl_out.Tt = self.gas.t_from_h(h)
self.fl_out.Tt = self.gas.t_f_h(h, tol=1e-6)

self.tr = self.fl_out.Tt / self.fl_in.Tt
self.pr = self.gas.pr(self.fl_in.Tt, self.fl_out.Tt, self.eff_poly)
Expand Down
13 changes: 7 additions & 6 deletions pyturbo/systems/compressor/compressor_mft_aero.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@

from pyturbo.mft.compressor import SimplifiedMftCompressor
from pyturbo.ports import FluidPort
from pyturbo.thermo.ideal_gas import IdealGas
from pyturbo.thermo import IdealDryAir


class CompressorMftAero(System):
"""Calculate, from a compressor map, the thermodynamic characteristics.
Parameters
----------
FluidLaw: Class, default=IdealDryAir
Class providing gas characteristics
gas: Gas, default=IdealDryAir
gas model
Inputs
------
Expand All @@ -38,18 +38,19 @@ class providing gas characteristics
fluid leaving the compressor
"""

def setup(self):
def setup(self, gas=IdealDryAir):
# properties
self.add_inward("gas", gas())

self.add_input(FluidPort, "fl_in")
self.add_output(FluidPort, "fl_out")

self.add_inward("pcnr", 90.0, unit="%", desc="percentage of the reduced shaft speed")
self.add_inward("gh", 0.0, unit="J/kg", desc="enthalpy minimum loss delta")
self.add_inward("cmp_model", SimplifiedMftCompressor())
self.add_inward("gas", IdealGas(287.058, 1004.0)) # dry air

def compute(self):
self.fl_out.Tt = self.gas.t_from_h(self.gas.h(self.fl_in.Tt) + self.cmp_model.ghr(self.gh))
self.fl_out.Tt = self.gas.t_f_h(self.gas.h(self.fl_in.Tt) + self.cmp_model.ghr(self.gh))
self.fl_out.Pt = self.fl_in.Pt * self.cmp_model.pr(self.pcnr, self.gh)
self.fl_out.W = (
self.cmp_model.wr(self.pcnr, self.gh) * self.fl_out.Pt / np.sqrt(self.fl_out.Tt)
Expand Down
4 changes: 2 additions & 2 deletions pyturbo/systems/inlet/inlet_aero.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ def compute(self):

pt = self.fl_in.Pt
tt = self.fl_in.Tt
self.mach = self.gas.mach(pt, tt, self.fl_in.W / self.area)
self.mach = self.gas.mach_f_wqa(pt, tt, self.fl_in.W / self.area, tol=1e-6)

self.ps = self.gas.static_p(pt, tt, self.mach)
self.ps = self.gas.static_p(pt, tt, self.mach, tol=1e-6)
self.speed = self.mach * self.gas.c(tt)

self.drag = self.fl_in.W * self.speed + (self.ps - self.pamb) * self.area
8 changes: 4 additions & 4 deletions pyturbo/systems/nozzle/nozzle_aero.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,15 @@ def compute(self):
self.fl_out.Tt = self.fl_in.Tt

# assumes convergent nozzle (throat at exit)
self.mach = self.gas.mach_ptpstt(self.fl_in.Pt, self.pamb, self.fl_in.Tt)
self.mach = self.gas.mach_f_ptpstt(self.fl_in.Pt, self.pamb, self.fl_in.Tt, tol=1e-6)

ts = self.gas.static_t(self.fl_in.Tt, self.mach)
self.ps = self.gas.static_p(self.fl_in.Pt, self.fl_in.Tt, self.mach)
ts = self.gas.static_t(self.fl_in.Tt, self.mach, tol=1e-6)
self.ps = self.gas.static_p(self.fl_in.Pt, self.fl_in.Tt, self.mach, tol=1e-6)
rho = self.gas.density(self.ps, ts)
self.speed = self.gas.c(ts) * self.mach

if self.mach > 1.0:
self.fl_out.W = self.gas.Wqa_crit(self.fl_in.Pt, self.fl_in.Tt) * self.area
self.fl_out.W = self.gas.wqa_crit(self.fl_in.Pt, self.fl_in.Tt, tol=1e-6) * self.area
else:
self.fl_out.W = rho * self.speed * self.area

Expand Down
8 changes: 5 additions & 3 deletions pyturbo/systems/structures/channel_aero.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ def compute(self):
self.fl_out.Tt = self.fl_in.Tt
self.fl_out.Pt = self.fl_in.Pt * (1.0 - self.pressure_loss)

self.mach_in = self.gas.mach(self.fl_in.Pt, self.fl_in.Tt, self.fl_in.W / self.area_in)
self.mach_exit = self.gas.mach(
self.fl_out.Pt, self.fl_out.Tt, self.fl_out.W / self.area_exit
self.mach_in = self.gas.mach_f_wqa(
self.fl_in.Pt, self.fl_in.Tt, self.fl_in.W / self.area_in, tol=1e-6
)
self.mach_exit = self.gas.mach_f_wqa(
self.fl_out.Pt, self.fl_out.Tt, self.fl_out.W / self.area_exit, tol=1e-6
)
6 changes: 4 additions & 2 deletions pyturbo/systems/turbine/turbine_aero.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def compute(self):
# fluid
self.fl_out.W = self.fl_in.W
dh = self.dhqt * self.fl_in.Tt
self.fl_out.Tt = self.gas.t_from_h(self.gas.h(self.fl_in.Tt) - dh)
self.fl_out.Tt = self.gas.t_f_h(self.gas.h(self.fl_in.Tt) - dh, tol=1e-6)
self.fl_out.Pt = (
self.gas.pr(self.fl_in.Tt, self.fl_out.Tt, 1.0 / self.eff_poly) * self.fl_in.Pt
)
Expand All @@ -110,4 +110,6 @@ def compute(self):

# outwards
self.Wc = self.fl_in.Wc
self.Wcrit = self.gas.Wqa_crit(self.fl_in.Pt, self.fl_in.Tt) * self.area_in / self.blokage
self.Wcrit = (
self.gas.wqa_crit(self.fl_in.Pt, self.fl_in.Tt, tol=1e-6) * self.area_in / self.blokage
)
1 change: 0 additions & 1 deletion pyturbo/systems/turbofan/turbofan.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
from pyturbo.systems.turbofan.turbofan_aero import TurbofanAero
from pyturbo.systems.turbofan.turbofan_geom import TurbofanGeom
from pyturbo.systems.turbofan.turbofan_weight import TurbofanWeight
from pyturbo.thermo import IdealDryAir
from pyturbo.utils import JupyterViewable


Expand Down
Loading

0 comments on commit a0a57ae

Please sign in to comment.