Devashri commited on
Commit
aedc856
·
verified ·
1 Parent(s): a43b97b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -0
app.py CHANGED
@@ -42,6 +42,20 @@ if st.button('Generate Graph'):
42
  # Instructions or description can be added here
43
  st.write('The SIR model divides the population into three categories: Susceptible (S), Infected (I), and Recovered (R). The model simulates how an infectious disease spreads and is managed within a population over time.')
44
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45
  # Create an animated graph
46
  fig = go.Figure(data=[
47
  go.Scatter(x=times, y=s, name='Susceptible', mode='lines'),
 
42
  # Instructions or description can be added here
43
  st.write('The SIR model divides the population into three categories: Susceptible (S), Infected (I), and Recovered (R). The model simulates how an infectious disease spreads and is managed within a population over time.')
44
 
45
+ # Define the lists to store the population data over time
46
+ times = [] # List of time points
47
+ s = [] # List of susceptible population
48
+ i = [] # List of infected population
49
+ r = [] # List of recovered population
50
+
51
+ # Run the SIR model simulation and store the population data at each time step
52
+ while t <= duration:
53
+ times.append(t)
54
+ # Evaluate the model at each time step and store the population values
55
+ s.append(eg.enodes["id"].evaluable_outputs["out_port1"].curr_value)
56
+ i.append(eg.enodes["id"].evaluable_outputs["out_port2"].curr_value)
57
+ r.append(eg.enodes["id"].evaluable_outputs["out_port3"].curr_value)
58
+ t += dt
59
  # Create an animated graph
60
  fig = go.Figure(data=[
61
  go.Scatter(x=times, y=s, name='Susceptible', mode='lines'),