Jump to: navigation, search

The METHODS part of a MODEL is where procedural statements are contained. In this part of your model declaration, you can not declare new variables or equations, but you can set the values of variables, make equations active/inactive, perform bounds checking and run External Methods.

See Thin-walled_tank/Adding_methods_to_a_model for an introduction to the use of METHODS including some 'standard' method naming conventions.

Standard METHOD names

There is a suggested set of names for METHODs that you should consider using in a model if you would like to make it easy for other people to reuse it. These are

  • on_load
Write this method to make calls to the other METHODs in suitable sequence. The intention here is that after the GUI automatically runs this method, the model should be in a state where it 'just solves', so that the user can see what the results are.
  • default
Write this method to set initial guesses for any variables that you want to set. This method is used as part of automatic recursive initialisation.
  • specify
In this method, RUN ClearAll, then FIX any variables that you would like to set as known values.
  • values
In this method, set the values of your FIXed variables.
  • default_self
Set any other default values for variables in your model. Often, setting these default (initial/pre-solve) values this is necessary in order for your model to converge to the desired solution.
  • bound_self
Set the upper_bound and lower_bound for any variables that don't already have suitable bounds from their ATOM definitions.
Set (or re-set) the scaling for your model. Correct model scaling is critical for the good numerical behaviour of some models. Sometimes it can even be useful to re-scale the model after solving it with some 'easy' initial conditions.
  • self_test
Write this method with ASSERT statements to check that your model solves to the expected values. This allows you to quickly check that the model is working as you want, before then proceeding to use it for your other purposes. See Model self-testing.

Sometimes models require an unusual set of METHODs in order to be configured to solve the problem at hand. In this case, it is recommended that instructions for solving your model be added using NOTES on the model, perhaps giving the notes category as "solving", for example.

Built-in methods

  • ClearAll
This method automatically FREEs all variables in the whole model tree.
  • reset
This method runs ClearAll and then attempts to run the specify method. That means that all the FIXed and FREEd varibles should end up reset to their desired states.