-
-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathexample_flame.py
More file actions
56 lines (39 loc) · 1.33 KB
/
example_flame.py
File metadata and controls
56 lines (39 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#########################################################################################
##
## PathSim stiff flame ODE example
##
#########################################################################################
# IMPORTS ===============================================================================
import numpy as np
import matplotlib.pyplot as plt
from pathsim import Simulation, Connection
from pathsim.blocks import Scope, Integrator, Adder, Function
from pathsim.solvers import ESDIRK32, ESDIRK43, GEAR52A
# FLAME INITIAL VALUE PROBLEM ===========================================================
#flame parameter (very stiff)
delta = 0.0001
#blocks that define the system
Int = Integrator(delta)
Fnc = Function(lambda x: x**2 - x**3)
Sco = Scope()
blocks = [Int, Fnc, Sco]
#the connections between the blocks
connections = [
Connection(Int, Fnc, Sco),
Connection(Fnc, Int)
]
#initialize simulation with the blocks, connections, timestep and logging enabled
Sim = Simulation(
blocks,
connections,
dt=0.1,
Solver=ESDIRK43,
tolerance_lte_abs=1e-6,
tolerance_lte_rel=1e-4
)
# Run Example ===========================================================================
if __name__ == "__main__":
Sim.run(2/delta)
#plotting
Sco.plot(".-")
plt.show()