mtiller / ModelicaBook

Source for my new Modelica Book
https://mbe.modelica.university
Other
97 stars 71 forks source link

Start values topic should also mention fixed attribute #133

Closed tbeu closed 10 years ago

tbeu commented 10 years ago

When you speak about start values first time (in Lotka-Volterra Systems) you compare advantages and disadvantages with initial equations. What I miss here is the introduction of the fixed attribute which means - if set to fixed - that the start attribute is no longer just a hint but a fixed initial assignment.

tbeu commented 10 years ago

In fact almost all simple domain models use start values and fixed attributes. Also start values are easier to implement than initial equations for a Modelica compiler vendor.

tbeu commented 10 years ago

There is one more strong argument for using the start/fixed attributes in preference. You can modify them, i.e. set them by dialog.

tbeu commented 10 years ago

Mike, can you please commenr on this issue. I consider it as an important issue not just a matter of taste.

xogeny commented 10 years ago

Thomas, I agree with you in general on this point and I think more discussion on this topic is required in the book. I simply haven't had the time to invest in that part just yet. I have a conference coming up so I'm pretty busy with that at the moment. Hopefully once that is done I'll have a bit more time to think about this.

xogeny commented 10 years ago

Thomas, I've added some further discussion about fixed. I don't discuss the modification of start attributes because, frankly, if you really want to allow users to change such things, you should make them parameters (and that works with both initial equations and fixed=true).

tbeu commented 10 years ago

Maybe you also want to add a model that makes use of it. E.g. BasicEquations\LotkaVolterra\ClassicModelFixedStartValues.mo

tbeu commented 10 years ago

This is what I mean

within ModelicaByExample.BasicEquations.LotkaVolterra;
model ClassicModelFixedStartValues "This is the typical equation-oriented model"
  parameter Real alpha=0.1 "Reproduction rate of prey";
  parameter Real beta=0.02 "Mortality rate of predator per prey";
  parameter Real gamma=0.4 "Mortality rate of predator";
  parameter Real delta=0.02 "Reproduction rate of predator per prey";
  parameter Real x0=10 "Initial prey population";
  parameter Real y0=10 "Initial predator population";
  Real x(start=x0, fixed=true) "Prey population";
  Real y(start=y0, fixed=true) "Predator population";
equation
  der(x) = x*(alpha-beta*y);
  der(y) = y*(delta*x-gamma);
end ClassicModelFixedStartValues;