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:
@@ -35,8 +35,9 @@ if __name__ == '__main__':
|
||||
|
||||
sud = Sud("sude/sud_0010.json")
|
||||
|
||||
first_step = sud.schedule[0]
|
||||
plant_params = {
|
||||
**sud.derive_plant_params(),
|
||||
**sud.derive_plant_params(first_step['grain_mass'], first_step['water_mass']),
|
||||
"L" : 0.2,
|
||||
"Td" : 60
|
||||
}
|
||||
@@ -65,9 +66,15 @@ if __name__ == '__main__':
|
||||
stirrer.set_duty_cycle(1.0 if speed > 0 else 0.0)
|
||||
stirrer.set_speed(speed)
|
||||
|
||||
def apply_plant_params(step):
|
||||
params = sud.derive_plant_params(step['grain_mass'], step['water_mass'])
|
||||
plant.set_thermal_params(params['M'], params['C'])
|
||||
ctrl.set_model_params(params['M'], params['C'])
|
||||
|
||||
def on_step_changed(step):
|
||||
if step is not None:
|
||||
print(f"Step {step['number']}: {step['descr']}")
|
||||
apply_plant_params(step)
|
||||
if 'ramp' in step:
|
||||
ctrl.set_theta_soll(step['ramp']['temp'])
|
||||
ctrl.set_heatrate_soll(step['ramp']['rate'])
|
||||
|
||||
Reference in New Issue
Block a user