CPD320 Simulation Project

From Chemical Engineering @ UP wiki
Revision as of 10:58, 3 March 2011 by Alchemyst (Talk | contribs) (Deleted contact information for André)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

This page contains common problems concerning the CPD simulation project.

Mistakes specific to CPD project

Integration

Remember that you're working with one system. The states of the system affect each other - you will therefore need to integrate all the states at once. Splitting the differential equations and integrating them one at a time, will create problems as you'll assuming certain set profiles for variables (the pre-integrated states) and not allowing them to change according to the equations.

Diverging (unstable) differentials

If you notice that your system seems to be unstable (after integration) just check that you've not created a system which is inherently unstable. A few things to check include:

  • Check that your balances hold - are you removing mass/energy?
  • Check parameters - bad parameter choices can make the system seem unstable (due a very slow nature or steady-state being at very high values).
  • Are your equations working as you expect?
  • Is the control valve open? (x > 0)

Test your functions

Make sure that your functions return the values you expect them to by giving them known values and checking the output.

Be consistent

If you decide to use different functions for each differential equation, be consistent when specifying the order of the arguments to those functions. Its easy to make mistakes when you need to pass the arguments in a different order each time.

Variable names

Make sure that you don't use the same name for variables and functions, this will cause Octave to handle calls to your function/variable differently than you might expect. It will only call the function if the variable (which has the same name) does not exist.

Time

Take note that lsode does not make a number of integration steps equal to the size of the timespan you defined. Therefore, if you want to use time in any of your equations, you can not count on the n'th time step to correspond to the n'th element in your timespan vector (this will almost always be the case).

Common Octave errors

There is a separate page for Common Matlab/Octave errors.