`mixedflow_turbofan` example: `hp_shaft.HPX` (250 hp) has no effect, the shaft balances use `pwr_in`/`pwr_out`
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 76/100
Hướng nghiên cứu
Đọc example_cycles/mixedflow_turbofan.py ở phần cân bằng trục HP và LP, sau đó so sánh chúng với các cân bằng trong example_cycles/high_bypass_turbofan.py và example_cycles/N+3ref/N3ref.py. Issue bao gồm một đoạn mã tái hiện và báo cáo rằng kết quả thiết kế không thay đổi khi HPX được đặt thành 250 hp hoặc 0 hp. Cập nhật các kỳ vọng hồi quy trong example_cycles/tests/benchmark_mixedflow_turbofan.py nếu thay đổi cân bằng ảnh hưởng đến chúng, sau đó chạy bài kiểm thử benchmark đó; hoàn thành khi lượng trích HP ảnh hưởng đến điểm thiết kế và bài kiểm thử thành công.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Version: pyCycle 4.4.0 (also master ee7e1612), OpenMDAO 3.45.2, Python 3.12, Linux.
What happens. example_cycles/mixedflow_turbofan.py sets pyc_add_cycle_param('hp_shaft.HPX', 250, units='hp'),
but the turbine-PR (design) and shaft-speed (off-design) balances equate hp_shaft.pwr_in with hp_shaft.pwr_out
(lines 145-146 and 173-174). In Shaft.compute, pwr_in and pwr_out are built from the port torques only; HPX
enters trq_net, pwr_net and pwr_out_real. So the converged cycle draws no power extraction: the design
point is the same with HPX = 250 hp and HPX = 0, and hp_shaft.pwr_net ends at -HPX.
Design point of the example (its inputs; reproducer below):
| HPX = 250 hp | HPX = 0 | |
|---|---|---|
| W (lbm/s) | 53.83399716 | 53.83399716 |
| FAR_core | 0.03112487 | 0.03112487 |
| hpt.PR | 2.04302656 | 2.04302656 |
| hpt power (hp) | 2711.06378708 | 2711.06378708 |
| hpc power (hp) | -2711.06378708 | -2711.06378708 |
| hp_shaft.pwr_net (hp) | -250.0 | 0.0 |
The other examples include HPX in the balance: high_bypass_turbofan.py uses pwr_in_real/pwr_out_real
(lines 130-131, 178-179), N+3ref/N3ref.py balances hp_shaft.pwr_net (lines 124, 210).
Suggested fix. Connect hp_shaft.pwr_in_real and hp_shaft.pwr_out_real (as in high_bypass_turbofan.py)
in the HP balances, and likewise for the LP shaft for consistency (no HPX there, fracLoss 0, so no change in
its results). The example's regression values (example_cycles/tests/benchmark_mixedflow_turbofan.py) would
change, since the design then extracts 250 hp. If the intent was no extraction, removing the HPX cycle
parameter would make the example say so.
We have not run the example's benchmark test with the change.
Reproducer. hpx_repro.py runs the example's design point twice. With NumPy >= 2.5, pyCycle 4.4.0
needs the NumPy 2 fixes now on master (PR #117, commit 69703dd2); the script applies an equivalent run-time
shim only in that case (it passes shape-(1,) inputs as 0-d arrays; with it the example reproduces the
benchmark's W 53.833997155 lbm/s to every printed digit).
python hpx_repro.py example_cycles/mixedflow_turbofan.py
hpx_repro.py
"""pyCycle mixedflow_turbofan example: the HP shaft balance leaves HPX out.
Runs the example's design point with hp_shaft.HPX = 250 hp (the example's value) and 0 hp and prints the
results. Usage: python hpx_repro.py PATH/TO/example_cycles/mixedflow_turbofan.py
With NumPy >= 2.5, pyCycle 4.4.0 needs the NumPy 2 fixes now on master (PR #117, commit 69703dd2); the
compatibility shim below applies them at run time and is a no-op otherwise.
"""
import importlib.util
import inspect
import pkgutil
import sys
import numpy as np
import openmdao.api as om
import pycycle
# --- NumPy >= 2.5 shim for pyCycle 4.4.0: shape-(1,) inputs passed as 0-d arrays (values unchanged) ---
class _Zero(np.ndarray):
def __new__(cls, v):
return np.asarray(v).reshape(()).view(cls)
def __getitem__(self, k):
return np.asarray(self)[()] if (k in (0, -1) or k == slice(None)) else np.ndarray.__getitem__(self, k)
def __array_wrap__(self, arr, context=None, return_scalar=False):
return np.asarray(arr)[()] if np.ndim(arr) == 0 else np.asarray(arr)
class _View:
def __init__(self, i):
self._i = i
def __getitem__(self, k):
v = self._i[k]
return _Zero(v) if isinstance(v, np.ndarray) and v.shape == (1,) else v
def __getattr__(self, a):
return getattr(self._i, a)
if tuple(int(x) for x in np.__version__.split(".")[:2]) >= (2, 5):
for mod in pkgutil.walk_packages(pycycle.__path__, "pycycle."):
if ".test" in mod.name:
continue
try:
m = importlib.import_module(mod.name)
except ImportError:
continue
for _, cls in inspect.getmembers(m, inspect.isclass):
if cls.__module__ == m.__name__ and issubclass(cls, om.ExplicitComponent):
for meth in ("compute", "compute_partials"):
if meth in cls.__dict__:
orig = cls.__dict__[meth]
setattr(cls, meth, (lambda o: lambda self, i, *a, **k: o(self, _View(i), *a, **k))(orig))
# --- end shim ---
spec = importlib.util.spec_from_file_location("mixedflow_turbofan", sys.argv[1])
ex = importlib.util.module_from_spec(spec)
spec.loader.exec_module(ex)
def design(hpx):
prob = om.Problem()
prob.model = ex.MPMixedFlowTurbofan()
prob.setup(check=False)
for k, v, u in (('fc.alt', 35000., 'ft'), ('fc.MN', 0.8, None), ('balance.rhs:W', 5500.0, 'lbf'),
('balance.rhs:FAR_core', 3200, 'degR'), ('fan.PR', 3.3, None), ('fan.eff', 0.8948, None),
('lpc.PR', 1.935, None), ('lpc.eff', 0.9243, None), ('hpc.PR', 4.9, None), ('hpc.eff', 0.8707, None),
('hpt.eff', 0.8888, None), ('lpt.eff', 0.8996, None)):
prob.set_val('DESIGN.' + k, v, units=u) if u else prob.set_val('DESIGN.' + k, v)
prob.set_val('DESIGN.hp_shaft.HPX', hpx, units='hp')
for k, v in {'balance.FAR_core': 0.025, 'balance.FAR_ab': 0.025, 'balance.BPR': 1.0, 'balance.W': 100.,
'balance.lpt_PR': 3.5, 'balance.hpt_PR': 2.5, 'fc.balance.Pt': 5.2, 'fc.balance.Tt': 440.0,
'mixer.balance.P_tot': 100}.items():
prob['DESIGN.' + k] = v
for pt in prob.model.od_pts: # the OD point is part of the model; give it the example's guesses
for k, v in {'balance.FAR_core': 0.031, 'balance.FAR_ab': 0.038, 'balance.BPR': 2.2, 'balance.W': 60,
'balance.HP_Nmech': 15000, 'balance.LP_Nmech': 5000, 'fc.balance.Pt': 5.2, 'fc.balance.Tt': 440.0,
'mixer.balance.P_tot': 100, 'hpt.PR': 2.5, 'lpt.PR': 3.5, 'fan.map.RlineMap': 2.0,
'lpc.map.RlineMap': 2.0, 'hpc.map.RlineMap': 2.0}.items():
prob[pt + '.' + k] = v
prob.set_solver_print(level=-1)
prob.run_model()
g = lambda n, u=None: float(prob.get_val('DESIGN.' + n, units=u)[0]) if u else float(prob.get_val('DESIGN.' + n)[0])
return {"HPX (hp)": g('hp_shaft.HPX', 'hp'), "W (lbm/s)": g('inlet.Fl_O:stat:W', 'lbm/s'), "FAR_core": g('balance.FAR_core'),
"hpt.PR": g('hpt.PR'), "hpt power (hp)": g('hpt.power', 'hp'), "hpc power (hp)": g('hpc.power', 'hp'),
"hp_shaft.pwr_net (hp)": g('hp_shaft.pwr_net', 'hp'), "hp_shaft.pwr_out_real (hp)": g('hp_shaft.pwr_out_real', 'hp')}
from importlib.metadata import version
print("numpy", version("numpy"), "openmdao", version("openmdao"), "pycycle", version("om-pycycle"))
for hpx in (250.0, 0.0):
print({k: round(v, 8) for k, v in design(hpx).items()})
Output (pyCycle 4.4.0, OpenMDAO 3.45.2, NumPy 2.5.5):
numpy 2.5.5 openmdao 3.45.2 pycycle 4.4.0
{'HPX (hp)': 250.0, 'W (lbm/s)': 53.83399716, 'FAR_core': 0.03112487, 'hpt.PR': 2.04302656, 'hpt power (hp)': 2711.06378708, 'hpc power (hp)': -2711.06378708, 'hp_shaft.pwr_net (hp)': -250.0, 'hp_shaft.pwr_out_real (hp)': -2961.06217553}
{'HPX (hp)': 0.0, 'W (lbm/s)': 53.83399716, 'FAR_core': 0.03112487, 'hpt.PR': 2.04302656, 'hpt power (hp)': 2711.06378708, 'hpc power (hp)': -2711.06378708, 'hp_shaft.pwr_net (hp)': 0.0, 'hp_shaft.pwr_out_real (hp)': -2711.06217553}
- Ngôn ngữ chính
- Python
- Star
- 212
- Fork
- 101
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Không có hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của OpenMDAO/pyCycle
-
`PsResid` keeps its guess cache outside OpenMDAO's vectors, so `load_case` doesn't reproduce off-design solvesCó thể đã có người làm @Jhawk414 đã nhận 10 ngày trước. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 68/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 45/100
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 42/100
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 30/100
Tất cả issue của OpenMDAO/pyCycle
Issue tương tự
-
Test: to_hijri() accepts datetime.datetime and uses only the date partCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mởgood first issue
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 95/100
omarelshamy25x/shamy-hijri#63 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
polish
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
521xueweihan/HelloGitHub#4729 ·
-
[Bug]: Score parser reads parts of scientific notation as valid scoresCó thể đã có người làm @AshutoshSingh840 đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
UKGovernmentBEIS/control-arena#992 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 92/100
mvalentsev/awesome-free-ai-coding#70 ·
Maintainer thường phản hồi trong vòng 1 ngày