erical calculation from forward Eulerian to backward Eulerian approach?

EBK JAVA PROGRAMMING
8th Edition
ISBN:9781305480537
Author:FARRELL
Publisher:FARRELL
Chapter16: Graphics
Section: Chapter Questions
Problem 17RQ
icon
Related questions
Question

Question: How can I revise this model code so that to change the numerical calculation from forward Eulerian to backward Eulerian approach?

 
import numpy as np
import matplotlib.pyplot as plt
#A 1-box model
#dc/dt = S/V - kc
def one_box(S,k,c0, t):
#define timestep, minute
dt = 120
#Initial condition
tt = 0
ct = c0
#Volume of the box
V = 1 #1*1*1 km^3
#Start time-stepping loop
while tt < t:
#calculate the concentration change rate for one timestep, s-1
f = S/V k*ct
#calculate the concentration at the end of this timestep
ct = ct + f* dt
#advance to next timestep
tt = tt + dt
return ct
Transcribed Image Text:import numpy as np import matplotlib.pyplot as plt #A 1-box model #dc/dt = S/V - kc def one_box(S,k,c0, t): #define timestep, minute dt = 120 #Initial condition tt = 0 ct = c0 #Volume of the box V = 1 #1*1*1 km^3 #Start time-stepping loop while tt < t: #calculate the concentration change rate for one timestep, s-1 f = S/V k*ct #calculate the concentration at the end of this timestep ct = ct + f* dt #advance to next timestep tt = tt + dt return ct
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Intelligent Machines
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781305480537
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT