Skip to content

Commit 76232a3

Browse files
committed
update
1 parent 2cd85e6 commit 76232a3

File tree

2 files changed

+40
-18
lines changed

2 files changed

+40
-18
lines changed

src/neqsim/thermo/thermoTools.py

Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -374,10 +374,16 @@ def __init__(self):
374374
]
375375
if phase_change is not None:
376376
triple_point_candidates.append(getattr(phase_change, "Tt", None))
377-
self._triple_point = next((func for func in triple_point_candidates if func), None)
378-
self._tb = getattr(phase_change, "Tb", None) if phase_change is not None else None
377+
self._triple_point = next(
378+
(func for func in triple_point_candidates if func), None
379+
)
380+
self._tb = (
381+
getattr(phase_change, "Tb", None) if phase_change is not None else None
382+
)
379383
self._molecular_weight = (
380-
getattr(elements, "molecular_weight", None) if elements is not None else None
384+
getattr(elements, "molecular_weight", None)
385+
if elements is not None
386+
else None
381387
)
382388

383389
def get_component(self, name: str) -> _ChemicalComponentData:
@@ -416,17 +422,22 @@ def get_component(self, name: str) -> _ChemicalComponentData:
416422
pc=float(pc) / 1.0e5, # chemicals returns pressure in Pa
417423
omega=float(omega),
418424
molar_mass=molar_mass,
419-
normal_boiling_point=
420-
float(normal_boiling_point) if normal_boiling_point is not None else None,
421-
triple_point_temperature=
425+
normal_boiling_point=(
426+
float(normal_boiling_point)
427+
if normal_boiling_point is not None
428+
else None
429+
),
430+
triple_point_temperature=(
422431
float(triple_point_temperature)
423432
if triple_point_temperature is not None
424-
else None,
433+
else None
434+
),
425435
critical_volume=critical_volume,
426-
critical_compressibility=
436+
critical_compressibility=(
427437
float(critical_compressibility)
428438
if critical_compressibility is not None
429-
else None,
439+
else None
440+
),
430441
)
431442

432443
@staticmethod
@@ -491,6 +502,7 @@ def _apply_extended_properties(
491502
continue
492503
setter(value)
493504

505+
494506
def _system_interface_class():
495507
"""Return the JPype proxy for ``neqsim.thermo.system.SystemInterface``."""
496508

@@ -536,16 +548,18 @@ def addComponent(self, name, amount, *args): # noqa: N802 - Java signature
536548
alias_name = _resolve_alias(name)
537549
component_data = None
538550

539-
if getattr(self, "_use_extended_database", False) and not _has_component_in_database(
540-
alias_name
541-
):
551+
if getattr(
552+
self, "_use_extended_database", False
553+
) and not _has_component_in_database(alias_name):
542554
try:
543555
provider = _get_extended_provider(self)
544556
component_data = provider.get_component(name)
545557
except (ExtendedDatabaseError, ModuleNotFoundError):
546558
component_data = None
547559

548-
if component_data is not None and not _args_look_like_component_properties(args):
560+
if component_data is not None and not _args_look_like_component_properties(
561+
args
562+
):
549563
if args:
550564
raise NotImplementedError(
551565
"Extended database currently supports components specified in moles (unit='no') "
@@ -1354,7 +1368,9 @@ def addComponent(thermoSystem, name, moles, unit="no", phase=-10):
13541368
"""
13551369
alias_name = _resolve_alias(name)
13561370

1357-
if getattr(thermoSystem, "_use_extended_database", False) and not _has_component_in_database(alias_name):
1371+
if getattr(
1372+
thermoSystem, "_use_extended_database", False
1373+
) and not _has_component_in_database(alias_name):
13581374
try:
13591375
provider = _get_extended_provider(thermoSystem)
13601376
component_data = provider.get_component(name)
@@ -2546,4 +2562,4 @@ def WAT(testSystem):
25462562
testFlash = thermodynamicoperations(testSystem)
25472563
testFlash.calcWAT()
25482564
testSystem.init(3)
2549-
return testSystem.getTemperature()
2565+
return testSystem.getTemperature()

tests/test_extended_database.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,17 @@ def test_use_extended_database_allows_missing_component():
3434

3535
normal_boiling_point = Tb(cas)
3636
if normal_boiling_point is not None:
37-
assert pytest.approx(component.getNormalBoilingPoint(), rel=1e-6) == normal_boiling_point
37+
assert (
38+
pytest.approx(component.getNormalBoilingPoint(), rel=1e-6)
39+
== normal_boiling_point
40+
)
3841

3942
critical_volume = Vc(cas)
4043
if critical_volume is not None:
41-
assert pytest.approx(component.getCriticalVolume(), rel=1e-6) == critical_volume * 1.0e6
44+
assert (
45+
pytest.approx(component.getCriticalVolume(), rel=1e-6)
46+
== critical_volume * 1.0e6
47+
)
4248

4349
critical_compressibility = Zc(cas)
4450
if critical_compressibility is not None:
@@ -68,4 +74,4 @@ def test_module_add_component_uses_extended_database():
6874
system.useExtendedDatabase(True)
6975
addComponent(system, "dimethylsulfoxide", 1.0)
7076

71-
assert system.getPhase(0).hasComponent("dimethylsulfoxide")
77+
assert system.getPhase(0).hasComponent("dimethylsulfoxide")

0 commit comments

Comments
 (0)