HW12: More Solving of Ordinary Differential Equations (ODEs)#
Problem 1: Solve the following differential equation using odeint#
If you are living on the International Space Station and accidentally get ejected into space without a space suit, you would need to get air within a few minutes to prevent death. Even if you have air, if you aren’t kept warm, your body would be hypothermic in a relatively short period. Let find out how long you have to get back to the space station before becoming hypothermic. There are likely other more deadly conditions of being exposed to a vacuum than running out of oxygen or freezing, but we will ignore those for now.
Assuming your are on the shadowed side of Earth, the following is a simple model that describes how your body’s average temperature \(T\) could change in time. The term on the left is the accumulation term; the first term on the right is a generation term (from your metabolism); the second term on the right is emission by radiation into space (space does not return any radiation to you).
where \(m\) is total body mass, \(c_p\) is heat capacity, \(\dot{Q}\) is heat generation by your body, \(A\) is effective surface area of your body that emits radiation, and \(\sigma\) is the Stefan-Boltzmann radiation constant (look it up online).
Your code should be well-documented and all constants should be specified with units. You should use SI units generally in this problem, though will need to switch between \(\mathrm{K}\) and \(^\circ\mathrm{C}\). A couple notes on that: Temperature in the radiation term must be absolute (i.e. units \(\mathrm{K}\)). Recall from ChEn 170 that for heat capacity the denominator contains a change in temperature (i.e. either \(\Delta\mathrm{K}\) or \(\Delta^\circ\mathrm{C}\) which are perfectly the same). Once you get an answer in \(\mathrm{K}\) you will need to convert to \(^\circ\mathrm{C}\) in the final plot.
To solve this problem you need to do the following.
Reasonably estimate the values of \(m\) and \(A\) for your body (or for ‘a friend’). The area that emits radiation could be estimated, for instance, by treating your body as if it were a cylinder of water.
Assume \(c_p\) for your body is the value for water
Reasonably estimate what your \(\dot{Q}\) would be in this scenario: a person while resting generates about \(100~\mathrm{W}\) heat and while vigorously exercising generates around \(300~\mathrm{W}\).
Rearrange the above equation and determine what is needed to implement into
odeint
Make a smooth well-formatted plot of body temperature (\(^\circ\mathrm{C}\)) over time (\(\mathrm{s}\)). Adjust the timescale so that the plot readily shows the most relevant region of interest.
Based on the plot of the model result, estimate the time when you would get to hypothermia. Normal body temperature is \(37^\circ\mathrm{C}\); hypothermia begins at \(35^\circ\mathrm{C}\).
#Your answer here
Problem 2: Use ODEINT#
Use ODEINT to solve the Lorenz Equations given in the class module. The class module used a loop and Euler’s method to solve the equations. You should be able to use ODEINT to solve the equations. Use the same parameters for your solution: sigma=10; rho=28; beta=8/3; initial conditions: x=10, y=10, z=10.
Plot the x, y, and z variables over time as is done in the class module on a 3D plot. Does your solution match the class module solution?
Problem 3: More ODE Practice#
Use any method to solve the last differential equation in the class module and compare your results with the data for the CO2 concentration versus time. The equation is given by:
Use the following parameters: \(k_1=220\) and \(k_2=1.7\). The initial condition is df[‘CO₂’].iloc[-594]. The iloc is a location point (row) in the data frame. Plot rows -594 to -550 as is done in the class module. How could you optimize the parameters to better fit the data?