Skip to content

Commit d00cbd8

Browse files
slayoojcurtis2
andauthored
add a basic test case draft checking parsing of chamber loss_function params (#369)
Co-authored-by: Jeffrey Curtis <[email protected]>
1 parent 1853f40 commit d00cbd8

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

tests/test_scenario.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,3 +321,38 @@ def test_throws_if_profile_not_of_proper_form(prof, data, msg):
321321

322322
# assert
323323
assert str(excinfo.value) == msg.replace("PROF", f"{prof}")
324+
325+
@staticmethod
326+
def test_loss_function_chamber():
327+
# arrange
328+
aero_data = ppmc.AeroData(AERO_DATA_CTOR_ARG_MINIMAL)
329+
gas_data = ppmc.GasData(GAS_DATA_CTOR_ARG_MINIMAL)
330+
env_state = ppmc.EnvState(ENV_STATE_CTOR_ARG_MINIMAL)
331+
ctor_arg = copy.deepcopy(SCENARIO_CTOR_ARG_MINIMAL)
332+
ctor_arg["loss_function"] = "chamber"
333+
ctor_arg["chamber_vol"] = 1.0
334+
ctor_arg["area_diffuse"] = 1.0
335+
ctor_arg["area_sedi"] = 1.0
336+
ctor_arg["prefactor_BL"] = 1.0
337+
ctor_arg["exponent_BL"] = 1.0
338+
339+
# act
340+
sut = ppmc.Scenario(gas_data, aero_data, ctor_arg)
341+
sut.init_env_state(env_state, 0.0)
342+
343+
# assert
344+
assert ppmc.loss_rate(sut, 1e-20, 1000.0, aero_data, env_state) > 0.0
345+
346+
@staticmethod
347+
def test_loss_function_constant():
348+
# arrange
349+
aero_data = ppmc.AeroData(AERO_DATA_CTOR_ARG_MINIMAL)
350+
gas_data = ppmc.GasData(GAS_DATA_CTOR_ARG_MINIMAL)
351+
env_state = ppmc.EnvState(ENV_STATE_CTOR_ARG_MINIMAL)
352+
ctor_arg = copy.deepcopy(SCENARIO_CTOR_ARG_MINIMAL)
353+
ctor_arg["loss_function"] = "constant"
354+
355+
# act
356+
sut = ppmc.Scenario(gas_data, aero_data, ctor_arg)
357+
358+
assert ppmc.loss_rate(sut, 1e-20, 1000.0, aero_data, env_state) == 0.001

0 commit comments

Comments
 (0)