Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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