Make grain_mass/water_mass per-step and re-derive plant params on change
grain_mass and water_mass now live on each step (defaulted from default.step) instead of being fixed for the whole brew, since both change over a mash (malt going in, water boiling off). Sud.derive_plant_params() takes them as arguments so it can be recomputed per step; the demo re-applies the resulting M/C to both the real plant and the controller's Smith-predictor model on every step change via the new Pot.set_thermal_params()/ TempController.set_model_params(). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CgR9tPaSzFkAwRAUyeaaCD
This commit is contained in:
+10
-9
@@ -37,7 +37,7 @@ def _build_step(number, defaults, raw_step):
|
||||
ramp or a hold depending on which of those keys it specifies; the other
|
||||
is left out rather than synthesized from defaults."""
|
||||
step = {'number': number}
|
||||
for key in ('descr', 'user_message', 'user_wait_for_continue'):
|
||||
for key in ('descr', 'user_message', 'user_wait_for_continue', 'grain_mass', 'water_mass'):
|
||||
step[key] = raw_step.get(key, defaults.get(key))
|
||||
for key in ('ramp', 'hold'):
|
||||
if key in raw_step:
|
||||
@@ -59,8 +59,6 @@ class Sud(AttributeChange):
|
||||
|
||||
self.pot_mass = data.get('pot_mass', 0)
|
||||
self.pot_material = data.get('pot_material')
|
||||
self.grain_mass = data.get('grain_mass', 0)
|
||||
self.water_mass = data.get('water_mass', 0)
|
||||
|
||||
self.index = -1
|
||||
self.hold_remaining = 0.0
|
||||
@@ -68,13 +66,16 @@ class Sud(AttributeChange):
|
||||
self.step = None
|
||||
self.user_message = None
|
||||
|
||||
def derive_plant_params(self):
|
||||
"""Lumped (mass, specific heat) lifted from pot_mass/pot_material/
|
||||
grain_mass/water_mass, for use as Pot's "M"/"C" params."""
|
||||
def derive_plant_params(self, grain_mass, water_mass):
|
||||
"""Lumped (mass, specific heat) lifted from pot_mass/pot_material and
|
||||
the current step's grain_mass/water_mass, for use as Pot's "M"/"C"
|
||||
params. grain_mass/water_mass vary per step (e.g. malt going in,
|
||||
water boiling off), so this is recomputed on every step change
|
||||
rather than once at startup."""
|
||||
c_pot = SPECIFIC_HEAT_BY_MATERIAL.get(self.pot_material, SPECIFIC_HEAT_WATER)
|
||||
mass = self.water_mass + self.grain_mass + self.pot_mass
|
||||
capacitance = (self.water_mass * SPECIFIC_HEAT_WATER
|
||||
+ self.grain_mass * SPECIFIC_HEAT_GRAIN
|
||||
mass = water_mass + grain_mass + self.pot_mass
|
||||
capacitance = (water_mass * SPECIFIC_HEAT_WATER
|
||||
+ grain_mass * SPECIFIC_HEAT_GRAIN
|
||||
+ self.pot_mass * c_pot)
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user