优化仿真求解性能并修复流量闭合问题(初版)
This commit is contained in:
1 parent
57b459bc72
commit
5332a788f3
55 files changed
+8973
-549
No files matched your search
@@ -6,17 +6,12 @@ from unittest.mock import Mock, patch
|
||||
from app.simulation.components.amesim.media.mediums import (
|
||||
AmesimHeliumPengRobinsonMedium,
|
||||
)
|
||||
from app.simulation.property_cache import property_cache_run
|
||||
|
||||
|
||||
class PropertyPerformanceInstrumentationTests(unittest.TestCase):
|
||||
def setUp(self) -> None:
|
||||
self.medium = AmesimHeliumPengRobinsonMedium()
|
||||
self.medium.temperature_from_pressure_enthalpy.cache_clear()
|
||||
self.medium.properties_from_mU.cache_clear()
|
||||
|
||||
def tearDown(self) -> None:
|
||||
self.medium.temperature_from_pressure_enthalpy.cache_clear()
|
||||
self.medium.properties_from_mU.cache_clear()
|
||||
|
||||
def test_temperature_iterations_are_recorded_only_on_cache_miss(self) -> None:
|
||||
pressure = 15.3e6
|
||||
@@ -30,14 +25,15 @@ class PropertyPerformanceInstrumentationTests(unittest.TestCase):
|
||||
"app.simulation.components.amesim.media.mediums."
|
||||
"record_property_iterations"
|
||||
) as record_iterations:
|
||||
first = self.medium.temperature_from_pressure_enthalpy(
|
||||
pressure,
|
||||
enthalpy,
|
||||
)
|
||||
second = self.medium.temperature_from_pressure_enthalpy(
|
||||
pressure,
|
||||
enthalpy,
|
||||
)
|
||||
with property_cache_run():
|
||||
first = self.medium.temperature_from_pressure_enthalpy(
|
||||
pressure,
|
||||
enthalpy,
|
||||
)
|
||||
second = self.medium.temperature_from_pressure_enthalpy(
|
||||
pressure,
|
||||
enthalpy,
|
||||
)
|
||||
|
||||
self.assertEqual(second, first)
|
||||
record_iterations.assert_called_once()
|
||||
@@ -60,8 +56,17 @@ class PropertyPerformanceInstrumentationTests(unittest.TestCase):
|
||||
"app.simulation.components.amesim.media.mediums."
|
||||
"record_property_iterations"
|
||||
) as record_iterations:
|
||||
first = self.medium.properties_from_mU(mass, internal_energy, volume)
|
||||
second = self.medium.properties_from_mU(mass, internal_energy, volume)
|
||||
with property_cache_run():
|
||||
first = self.medium.properties_from_mU(
|
||||
mass,
|
||||
internal_energy,
|
||||
volume,
|
||||
)
|
||||
second = self.medium.properties_from_mU(
|
||||
mass,
|
||||
internal_energy,
|
||||
volume,
|
||||
)
|
||||
|
||||
self.assertIs(second, first)
|
||||
record_iterations.assert_called_once()
|
||||
|
||||
Reference in new issue
Block a user