=====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** - Create a [[time point]] block - Edit the block. - In the **Properties** screen - change the name to "Garbage_day". - In the **Values** screen - Ensure that the **Dimension** is **Scalar** - Click the **Settings** button. - Change the **Mode** to **Day**. - Select _Tuesday_ as the **Timepoint** in the table. - Close the window **Create event** - Create a [[time event]] block - Edit the block. - In the **Properties** screen - Change the name to "Garbage event". - In the **Values** screen - Ensure that the **Dimension** is **Scalar** - Select **Garbage day** and click the **>** button. - Close the window **Create a source block** - Create a [[source/sink]] block - Edit the block - In the **Properties** screen, - Change the name to **Garbage truck** - Close the window **Create a transfer block** - Create a [[transfer]] block from _Garbage truck_ to _Soil_ - Edit the block - In the **Value** screen, - Enter the equation "50+sin(time/30)*50" which will give us a more or less random value between 0.0 and 100.0 - Select _Garbage event_ in the **Event** field - Close the window **Run a simulation** - Run a simulation, then plot _Soil_. - The plot should look like this: {{ :time_event_tutorial_garbage_day.png?600 |}} You can download the solution {{ :garbage_day_model.eco |here}} [[tutorial - time events - monthly max with memory|Previous]] ===== See also ===== * [[tutorial - time events|First page]] * [[tutorials|Tutorials]]