jckantor / TCLab

Software support for the Temperature Control Laboratory.
Apache License 2.0
13 stars 22 forks source link

How to start the simulated lab model with a different ambient temperature #109

Open billtubbs opened 5 years ago

billtubbs commented 5 years ago

I don't think there's an obvious way to set the ambient temperature for the TCLabModel (simulated version) so that the heater temperatures start at a temperature other than the default value (Ta = 21).

As far as I can tell, T1 and T2 are initialized in the __init__ method but there is no way to set Ta before this happens and no good way to change T1 and T2 after that (other than lab._T1 = ...).

Or am I missing something?

billtubbs commented 5 years ago

If this is true, I'm willing to help fix it.

alchemyst commented 4 years ago

Extending the model would be very useful, I think. In addition to the things you mention (changing ambient temperature and setting the temperatures), I can also think of changing the heat transfer coefficients to simulate blowing on the fins as a disturbance. Not having an easy disturbance is a major shortcoming of the model as it stands.

@jckantor How do you feel about extensions to the model?

billtubbs commented 4 years ago

I agree there are a few improvements possible.

Quick fix to my immediate problem:

  1. Make Ta an argument of __init__ so user can specify ambient temperature. This would mean the template of TCLabModel is no longer identical to the real lab but at least it's fully substitutable.

Other easy enhancements:

  1. Make Ta and possibly other parameters/constants into class properties so they can be varied during an experiment to simulate disturbances.

I would do these first.

I also thought this might be useful sometimes:

  1. Add a reset() method which resets the model instance to it's startup conditions (i.e. T1 = T2 = Ta) - (although this makes the simulation model less realistic!)

This 3rd one might take some more thinking about...

Let me know, I could have a go at these tomorrow and submit a pull request if you like.

alchemyst commented 4 years ago

Exposing the parameters makes sense to me. Could you elaborate on why you would want a reset() method rather than simply creating a new object?

billtubbs commented 4 years ago

True, you can always instantiate a new object. If I can set the ambient temperature every time I create a new one that would be fine. The scenario where a reset becomes more convenient is if you have adjusted a few parameters to certain non-default settings and want to repeat the experiment from the initial condition (T1 = T2 = Ta).

It's not a big deal though.