added tests for two-point control method, not working for some

This commit is contained in:
Christopher Neal 2024-06-14 17:35:15 -04:00 committed by Ray Speth
parent b357c79f53
commit b22f6f035d
2 changed files with 59 additions and 5 deletions

View File

@ -389,7 +389,7 @@ public:
//! Sets the status of the two-point control
void enableTwoPointControl(bool twoPointControl) {
if (m_usesLambda){
if (isStrained()){
m_twoPointControl = twoPointControl;
} else {
throw CanteraError("StFlow::enableTwoPointControl",

View File

@ -1243,7 +1243,9 @@ class TestDiffusionFlame(utilities.CanteraTest):
# round-trip solution.
self.assertArrayNear(temperature_2, temperature_4, rtol=1e-4, atol=1e-6)
# Test 3
'''
filename = self.test_work_path / "two_point_control.yaml"
original_settings = sim.flame.settings
@ -1253,11 +1255,63 @@ class TestDiffusionFlame(utilities.CanteraTest):
restored_settings = sim.flame.settings
assert 'continuation-method' in restored_settings
assert restored_settings['continuation-method']['type'] == original_settings['continuation-method']['type']
assert restored_settings['continuation-method']['left-location'] == original_settings['continuation-method']['left-location']
assert restored_settings['continuation-method']['right-location'] == original_settings['continuation-method']['right-location']
assert restored_settings['continuation-method']['left-temperature'] == original_settings['continuation-method']['left-temperature']
assert restored_settings['continuation-method']['right-temperature'] == original_settings['continuation-method']['right-temperature']
assert restored_settings['continuation-method']['left-location'] == pytest.approx(
original_settings['continuation-method']['left-location'],1e-4)
assert restored_settings['continuation-method']['right-location'] == pytest.approx(
original_settings['continuation-method']['right-location'],1e-4)
assert restored_settings['continuation-method']['left-temperature'] == pytest.approx(
original_settings['continuation-method']['left-temperature'],1e-4)
assert restored_settings['continuation-method']['right-temperature'] == pytest.approx(
original_settings['continuation-method']['right-temperature'],1e-4)
'''
# Test 4 - Check error conditions
# Create a fresh sim with un-set two-point control variables
#sim = ct.CounterflowDiffusionFlame(gas, width=width)
sim.two_point_control_enabled = False
print(sim.two_point_control_enabled)
sim.right_control_point_temperature = 300
#with pytest.raises(ct.CanteraError, match="two-point control is not enabled"):
# sim.right_control_point_temperature = 300
'''
with pytest.raises(ct.CanteraError, match="two-point control is not enabled"):
sim.right_control_point_temperature
with pytest.raises(ValueError, match="two-point control is not enabled"):
sim.left_control_point_temperature = 300
with pytest.raises(ValueError, match="two-point control is not enabled"):
sim.left_control_point_temperature
with pytest.raises(ValueError, match="No domain with two-point control enabled was found"):
sim.set_left_control_point(1)
with pytest.raises(ValueError, match="No domain with two-point control enabled was found"):
sim.set_right_control_point(1)
sim.two_point_control_enabled = True
with pytest.raises(ValueError, match="left control point location is not set"):
sim.left_control_point_coordinate
with pytest.raises(ValueError, match="left control point location is not set"):
sim.left_control_point_temperature
with pytest.raises(ValueError, match="right control point location is not set"):
sim.right_control_point_coordinate
with pytest.raises(ValueError, match="right control point location is not set"):
sim.right_control_point_temperature
'''
class TestCounterflowPremixedFlame(utilities.CanteraTest):
# Note: to re-create the reference file: