Developing ODE from data?
In the first example of this link I understand the methods used but what I don’t understand is how or why they assumed second order. Is it because it oscillated so that indicates second order due to change in concavity?
So if my data doesn’t oscillate and represents something more along the lines of half of a parabola does that mean I would only estimate the first derivative using finite differences?
I’m trying to obtain an equation to model the loss of CO2 from my can over time so as you can picture it, at t=0 the cO2 is high and eventually falls to 0 or atmospheric conditions. Those are my boundary conditions and initial conditions. But my cans initial concentration of co2 can change so ultimately I want a function where I can input the initial concentration then it can model the loss over time for me.
I’m teaching myself as I go off the internet so it’s confusing but I feel like I understand how to fit curves from what I’ve read and solve for coefficients for that particular data set but I’m wondering how to develop a model with everything already solved and just needs the initial condition as an input and it will model it
- hfshawLv 78 months agoFavorite Answer
One knows that the spring-mass system (the simple harmonic oscillator) is described by a second-order ODE from an analysis of the physics of the system.
Assumming the spring obeys Hooke's Law, the restoring force exerted by the spring as a function of its displacement from the equilibrium position is given by:
F = -k*y,
where y is the displacement, and k is the spring constant (a measure of the "stiffnesss" of the spring).
Newton's second law tells is that F = m*a, where F is the net force on an object of mass m, and a is the resulting acceleration of the object.
Remember that the acceleration is just the second derivative of the position, so inn 1-dimension, a = d²y/dt², and F = m*d²y/dt²
Equating the force in these two equations gives us:
m*d²y/dt² = -k*y
d²y/dt² = -(k/m)*y
which is the equation used in the first example in the link you provided.
The system you are trying to model (loss of CO2 from a can) is not well described, so it's not clear how to best model it. Is the CO2 in the can a gas?.....dissolved in water? If it's a gas, is the total pressure in the can equal to the ambient pressure or is it pressurized? Does the can have a large opening to the surrounding air, or is the CO2 escaping through a small orifice... or is it diffusing out through a porous plug...etc.?
The simplest case is might be to assume that the rate at which CO2 is lost from the container is proportional to the difference between the actual concentration at time t, and the equilibrium concentration (the concentration in the ambient atmosphere). If C(t) is the CO2 concentration at time t, and C_atm is the atmospheric concentration, we would model this as:
dC(t)/dt = -k*(C(t) - C_atm)
where k is some positive rate constant. Note that the right hand side has a negative sign because we know the C(t) is decreasing with time.
This is a separable, 1st-order ODE:
dC(t)/(C(t) - C_atm) = -k dt
Integrating this yields:
ln(C(t) - C_atm) = -k*t + D
where D is the constant of integration.
C(t) = C_atm + exp(D - k*t)
C(t) = C_atm + exp(D)*exp(k*t)
If the initial concentration of CO2 in the can at t = 0 is Co, then we can use this initial condition to determine the constant of integration:
C(0) = Co = C_atm + exp(D)*exp(0) = C_atm + exp(D)
exp(D) = (Co - C_atm)
Plugging this back into the solution gives the particular solution:
C(t) = C_atm + (Co - C_atm)*exp(-k*t)
At time t = 0, C(0) = Co, and as t -> ∞, the exponential factor goes to zero, so in the limit of t -> ∞, C(t) = C_atm, which is the general behavior I think you are looking for.
- 8 months ago
Your question is better suited on the math stack exchange forum. Are you confused why the ODE describing a spring is 2nd order? It's because the ODE's highest derivative is a second derivative – hence, its second order.