User Tools

Site Tools


tutorial_-_time_events_-_instant_pollution

Tutorial - Time events - Instant pollution

Sometimes one is interested in modelling processes that, when compared with the simulation time span, appear instantaneous. Very rapid processes will make life very difficult for the solver. The solver will either miss the transfer or it will crash when error tolerances cannot be met.

By associating an event with a transfer, we can perform the transfer outside of the solution. The solver will chug along until the event fires. It will then stop, we can mess with the current states, and then continue the simulation without the solver suspecting anything.

The unit of the transfer will change when it is discrete. Instead of mg/day or 1/day, the unit becomes either mg, or a fraction (unitless).

For our experiment, let us pretend that every Tuesday, a garbage truck appears and dumps a random amount of poison to the soil.

For this we need:

  • A time point block containing the day when the garbage truck arrives
  • An event which fires every day the garbage truck arrives (as given by the time point)
  • A source/sink block which represents the garbage truck
  • A transfer block to model the addition of poison

Create time point

  1. Create a time point block
  2. Edit the block.
  3. In the Properties screen
    1. change the name to “Garbage_day”.
  4. In the Values screen
    1. Ensure that the Dimension is Scalar
    2. Click the Settings button.
    3. Change the Mode to Day.
    4. Select _Tuesday_ as the Timepoint in the table.
  5. Close the window

Create event

  1. Create a time event block
  2. Edit the block.
  3. In the Properties screen
    1. Change the name to “Garbage event”.
  4. In the Values screen
    1. Ensure that the Dimension is Scalar
    2. Select Garbage day and click the > button.
  5. Close the window

Create a source block

  1. Create a source/sink block
  2. Edit the block
  3. In the Properties screen,
    1. Change the name to Garbage truck
  4. Close the window

Create a transfer block

  1. Create a transfer block from _Garbage truck_ to _Soil_
  2. Edit the block
  3. In the Value screen,
    1. Enter the equation “50+sin(time/30)*50” which will give us a more or less random value between 0.0 and 100.0
    2. Select _Garbage event_ in the Event field
  4. Close the window

Run a simulation

  1. Run a simulation, then plot _Soil_.
  2. The plot should look like this:

You can download the solution here

Previous

See also

tutorial_-_time_events_-_instant_pollution.txt · Last modified: 2023/03/15 09:36 by dmytroh