Skip to content

Commit

Permalink
add a basic test case draft checking parsing of chamber loss_function…
Browse files Browse the repository at this point in the history
… params (#369)

Co-authored-by: Jeffrey Curtis <[email protected]>
  • Loading branch information
slayoo and jcurtis2 authored Aug 8, 2024
1 parent 1853f40 commit d00cbd8
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions tests/test_scenario.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,3 +321,38 @@ def test_throws_if_profile_not_of_proper_form(prof, data, msg):

# assert
assert str(excinfo.value) == msg.replace("PROF", f"{prof}")

@staticmethod
def test_loss_function_chamber():
# arrange
aero_data = ppmc.AeroData(AERO_DATA_CTOR_ARG_MINIMAL)
gas_data = ppmc.GasData(GAS_DATA_CTOR_ARG_MINIMAL)
env_state = ppmc.EnvState(ENV_STATE_CTOR_ARG_MINIMAL)
ctor_arg = copy.deepcopy(SCENARIO_CTOR_ARG_MINIMAL)
ctor_arg["loss_function"] = "chamber"
ctor_arg["chamber_vol"] = 1.0
ctor_arg["area_diffuse"] = 1.0
ctor_arg["area_sedi"] = 1.0
ctor_arg["prefactor_BL"] = 1.0
ctor_arg["exponent_BL"] = 1.0

# act
sut = ppmc.Scenario(gas_data, aero_data, ctor_arg)
sut.init_env_state(env_state, 0.0)

# assert
assert ppmc.loss_rate(sut, 1e-20, 1000.0, aero_data, env_state) > 0.0

@staticmethod
def test_loss_function_constant():
# arrange
aero_data = ppmc.AeroData(AERO_DATA_CTOR_ARG_MINIMAL)
gas_data = ppmc.GasData(GAS_DATA_CTOR_ARG_MINIMAL)
env_state = ppmc.EnvState(ENV_STATE_CTOR_ARG_MINIMAL)
ctor_arg = copy.deepcopy(SCENARIO_CTOR_ARG_MINIMAL)
ctor_arg["loss_function"] = "constant"

# act
sut = ppmc.Scenario(gas_data, aero_data, ctor_arg)

assert ppmc.loss_rate(sut, 1e-20, 1000.0, aero_data, env_state) == 0.001

0 comments on commit d00cbd8

Please sign in to comment.