Skip to content

Commit

Permalink
pid morbidostat uses nOD, so make sure the class uses it explcitly
Browse files Browse the repository at this point in the history
  • Loading branch information
CamDavidsonPilon committed Nov 28, 2023
1 parent 91a183f commit 4d5b414
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 15 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
- Fix for Ngrok remote access
- Merged the turbidostat automations into one. You can either select target target nOD or target OD, but not both!
- Both "Target OD" and "Target nOD" are available to be changed in the UI.

- `pid_morbidostat` now explicitly uses the keyword arg `target_normalized_od`, instead of `target_od`. It always has been nOD.

### 23.11.18
- No more waiting around for growth-rate-calculating to get to "Ready" state
Expand Down
14 changes: 8 additions & 6 deletions pioreactor/automations/dosing/pid_morbidostat.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,16 @@ class PIDMorbidostat(DosingAutomationJob):
automation_name = "pid_morbidostat"
published_settings = {
"volume": {"datatype": "float", "settable": True, "unit": "mL"},
"target_od": {"datatype": "float", "settable": True, "unit": "AU"},
"target_normalized_od": {"datatype": "float", "settable": True, "unit": "AU"},
"target_growth_rate": {"datatype": "float", "settable": True, "unit": "h⁻¹"},
"duration": {"datatype": "float", "settable": True, "unit": "min"},
}

def __init__(self, target_growth_rate: float | str, target_od: float | str, **kwargs):
def __init__(
self, target_growth_rate: float | str, target_normalized_od: float | str, **kwargs
):
super(PIDMorbidostat, self).__init__(**kwargs)
assert target_od is not None, "`target_od` must be set"
assert target_normalized_od is not None, "`target_normalized_od` must be set"
assert target_growth_rate is not None, "`target_growth_rate` must be set"

with local_persistant_storage("current_pump_calibration") as cache:
Expand All @@ -39,7 +41,7 @@ def __init__(self, target_growth_rate: float | str, target_od: float | str, **kw
raise CalibrationError("Alt-Media pump calibration must be performed first.")

self.set_target_growth_rate(target_growth_rate)
self.target_od = float(target_od)
self.target_normalized_od = float(target_normalized_od)

Kp = config.getfloat("dosing_automation.pid_morbidostat", "Kp")
Ki = config.getfloat("dosing_automation.pid_morbidostat", "Ki")
Expand Down Expand Up @@ -105,11 +107,11 @@ def execute(self) -> events.AutomationEvent:

@property
def min_od(self):
return 0.7 * self.target_od
return 0.7 * self.target_normalized_od

@property
def max_od(self):
return 1.25 * self.target_od
return 1.25 * self.target_normalized_od

def set_target_growth_rate(self, value: str | float | int):
self.target_growth_rate = float(value)
Expand Down
16 changes: 8 additions & 8 deletions pioreactor/tests/test_dosing_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ def test_pid_morbidostat_automation() -> None:
experiment = "test_pid_morbidostat_automation"
target_growth_rate = 0.09
with PIDMorbidostat(
target_od=1.0,
target_normalized_od=1.0,
target_growth_rate=target_growth_rate,
duration=60,
unit=unit,
Expand Down Expand Up @@ -375,7 +375,7 @@ def test_changing_morbidostat_parameters_over_mqtt() -> None:
target_growth_rate = 0.05
algo = PIDMorbidostat(
target_growth_rate=target_growth_rate,
target_od=1.0,
target_normalized_od=1.0,
duration=60,
unit=unit,
experiment=experiment,
Expand Down Expand Up @@ -527,7 +527,7 @@ def test_throughput_calculator() -> None:
experiment,
"pid_morbidostat",
target_growth_rate=0.05,
target_od=1.0,
target_normalized_od=1.0,
duration=60,
) as algo:
assert algo.automation_job.media_throughput == 0
Expand Down Expand Up @@ -765,7 +765,7 @@ def test_execute_io_action_outputs_will_shortcut_if_disconnected() -> None:
def test_PIDMorbidostat() -> None:
experiment = "test_PIDMorbidostat"
algo = PIDMorbidostat(
target_od=1.0,
target_normalized_od=1.0,
target_growth_rate=0.01,
duration=5 / 60,
unit=unit,
Expand Down Expand Up @@ -801,7 +801,7 @@ def test_PIDMorbidostat() -> None:
def test_changing_duration_over_mqtt() -> None:
experiment = "test_changing_duration_over_mqtt"
with PIDMorbidostat(
target_od=1.0,
target_normalized_od=1.0,
target_growth_rate=0.01,
duration=5 / 60,
unit=unit,
Expand Down Expand Up @@ -831,7 +831,7 @@ def test_changing_duration_over_mqtt() -> None:
def test_changing_duration_over_mqtt_will_start_next_run_earlier() -> None:
experiment = "test_changing_duration_over_mqtt_will_start_next_run_earlier"
with PIDMorbidostat(
target_od=1.0,
target_normalized_od=1.0,
target_growth_rate=0.01,
duration=10 / 60,
unit=unit,
Expand Down Expand Up @@ -879,7 +879,7 @@ def test_changing_algo_over_mqtt_with_wrong_automation_type() -> None:
"type": "led",
"args": {
"duration": 60,
"target_od": 1.0,
"target_normalized_od": 1.0,
"target_growth_rate": 0.07,
},
}
Expand Down Expand Up @@ -909,7 +909,7 @@ def test_changing_algo_over_mqtt_solo() -> None:
"type": "dosing",
"args": {
"duration": 60,
"target_od": 1.0,
"target_normalized_od": 1.0,
"target_growth_rate": 0.07,
},
}
Expand Down

0 comments on commit 4d5b414

Please sign in to comment.