diff --git a/README.html b/README.html
new file mode 100644
index 0000000..3c0a669
--- /dev/null
+++ b/README.html
@@ -0,0 +1,69 @@
+
+
+
+
+
+
+ README
+
+
+
+
+
+Computational Mechanics 01 - Getting Started
+Working with Python and Numerical Methods
+Welcome to Computational Mechanics Module #1 - Getting Started!
+There are three modules and one final project. The modules will get us started on our exploration of computational mechanics using Python, listed below each module are the learning objectives.
+
+- 01_Interacting_with_Python
+
+
+- Using the
print()
function. The concept of function.
+- Using Python as a calculator.
+- Concepts of variable, type, assignment.
+- Special variables:
True
, False
, None
.
+- Supported operations, logical operations.
+- Reading error messages.
+
+
+- 02_Working_with_Python
+
+
+- Good coding habits and file naming
+- How to define a function and return outputs
+- How to import libraries
+- Multidimensional arrays using NumPy
+- Accessing values and slicing in NumPy arrays
+%%time
magic to time cell execution.
+- Performance comparison: lists vs NumPy arrays
+- Basic plotting with
pyplot
.
+
+
+- 03-Numerical_error
+
+
+- Numerical integration with the Euler approximation
+- The source of truncation errors
+- The source of roundoff errors
+- How to time a numerical solution or a function
+- How to compare solutions
+- The definition of absolute error and relative error
+- How a numerical solution converges
+
+
+We can use our current skillset for a macabre application. We can predict the time of death based upon the current temperature and change in temperature of a corpse.
+Forensic scientists use Newton’s law of cooling to determine the time elapsed since the loss of life,
+\(\frac{dT}{dt} = -K(T-T_a)\),
+where \(T\) is the current temperature, \(T_a\) is the ambient temperature, \(t\) is the elapsed time in hours, and \(K\) is an empirical constant.
+Suppose the temperature of the corpse is 85\(^o\)F at 11:00 am. Then, 2 hours later the temperature is 74\(^{o}\)F.
+Assume ambient temperature is a constant 65\(^{o}\)F.
+
+
diff --git a/README.md b/README.md
index 9721fc9..cb9ad6e 100644
--- a/README.md
+++ b/README.md
@@ -3,7 +3,7 @@
Welcome to Computational Mechanics Module #1 - Getting Started!
-There are three modules to get us started on our exploration of computational
+There are three modules and one final project. The modules will get us started on our exploration of computational
mechanics using Python, listed below each module are the learning objectives.
1. [01_Interacting_with_Python](./notebooks/01_Interacting_with_Python.ipynb)
@@ -33,3 +33,22 @@ mechanics using Python, listed below each module are the learning objectives.
* The definition of absolute error and relative error
* How a numerical solution converges
+## [Computational Mechanics Project #01 - Heat Transfer in Forensic Science](./project/01_Getting-started-project.ipynb)
+
+We can use our current skillset for a macabre application. We can predict the
+time of death based upon the current temperature and change in temperature of a
+corpse.
+
+Forensic scientists use Newton's law of cooling to determine the time elapsed
+since the loss of life,
+
+$\frac{dT}{dt} = -K(T-T_a)$,
+
+where $T$ is the current temperature, $T_a$ is the ambient temperature, $t$ is
+the elapsed time in hours, and $K$ is an empirical constant.
+
+Suppose the temperature of the corpse is 85$^o$F at 11:00 am. Then, 2 hours
+later the temperature is 74$^{o}$F.
+
+Assume ambient temperature is a constant 65$^{o}$F.
+
diff --git a/notebooks/.ipynb_checkpoints/03-Numerical_error-checkpoint.ipynb b/notebooks/.ipynb_checkpoints/03-Numerical_error-checkpoint.ipynb
index ad3586e..0449da2 100644
--- a/notebooks/.ipynb_checkpoints/03-Numerical_error-checkpoint.ipynb
+++ b/notebooks/.ipynb_checkpoints/03-Numerical_error-checkpoint.ipynb
@@ -1,5 +1,12 @@
{
"cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "###### Content modified under Creative Commons Attribution license CC-BY 4.0, code under BSD 3-Clause License © 2020 R.C. Cooper"
+ ]
+ },
{
"cell_type": "markdown",
"metadata": {
@@ -8,8 +15,8 @@
}
},
"source": [
- "# Freefall Model\n",
- "## Computational solution\n",
+ "# Numerical Error\n",
+ "## Freefall Model Computational solution\n",
"\n",
"
\n",
"\n",
@@ -383,7 +390,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
- "**Note:** In the above plot, the numerical solution is given discrete points connected by lines, while the analytical solution is drawn as a line. A helpful convention is to plot discrete data such as numerical solutions or measured data as points and lines while analytical solutions are drawn as lines. \n",
+ "**Note:** In the above plot, the numerical solution is given at discrete points connected by lines, while the analytical solution is drawn as a line. This is a helpful convention. We plot discrete data such as numerical solutions or measured data as points and lines while analytical solutions are drawn as lines. \n",
"\n",
"## Exercise\n",
"\n",
@@ -708,7 +715,9 @@
"\n",
"In the following example, we judge the **convergence** of our solution with the new knowledge of truncation error and roundoff error. \n",
"\n",
- "**Convergence is the trend that our solution progressively moves to a final *true* solution as we increase the fidelity of the model** ???\n",
+ "**The definition for convergence in mathematics is the limit of a sequence exists.** \n",
+ "\n",
+ "In the case of the Euler approximation, the sequence is smaller timesteps, $\\Delta t$, should converge to the analytical solution. \n",
"\n",
"Define time from 0 to 12 seconds with `N` timesteps \n",
"function defined as `freefall`\n",
@@ -1026,32 +1035,38 @@
" c. Use a growth rate of $k_g=0.013$ [1/years] and compare the analytical solution (use initial condition p(1900) = 1578000000) to the Euler integration for time steps of 20 years from 1900 to 2020 (Hint: use method (1)- plot the two solutions together with the given data) \n",
" \n",
" d. Discussion question: If you decrease the time steps further and the solution converges, will it converge to the actual world population? Why or why not? \n",
- "\n"
+ "\n",
+ "**Note: We have used a new function `np.loadtxt` here. Use the `help` or `?` to learn about what this function does and how the arguments can change the output. In the next module, we will go into more details on how to load data, plot data, and present trends.**"
]
},
{
"cell_type": "code",
- "execution_count": 301,
+ "execution_count": 12,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
- " year population\n",
- "0 1900 1578000000\n",
- "1 1950 2526000000\n",
- "2 2000 6127000000\n",
- "3 2020 7795482000\n"
+ "years= [1900. 1950. 2000. 2020.]\n",
+ "population = [1.578000e+09 2.526000e+09 6.127000e+09 7.795482e+09]\n"
]
}
],
"source": [
- "import pandas as pd\n",
- "data = pd.read_csv('../data/world_population_1900-2020.csv')\n",
- "print(data)"
+ "import numpy as np\n",
+ "year,pop=np.loadtxt('../data/world_population_1900-2020.csv',skiprows=1,delimiter=',',unpack=True)\n",
+ "print('years=',year)\n",
+ "print('population =', pop)"
]
},
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": []
+ },
{
"cell_type": "markdown",
"metadata": {},
@@ -1071,7 +1086,7 @@
},
{
"cell_type": "code",
- "execution_count": 273,
+ "execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
@@ -1090,6 +1105,13 @@
" return ex\n",
" "
]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": []
}
],
"metadata": {
diff --git a/notebooks/03-Numerical_error.ipynb b/notebooks/03-Numerical_error.ipynb
index 1633722..0449da2 100644
--- a/notebooks/03-Numerical_error.ipynb
+++ b/notebooks/03-Numerical_error.ipynb
@@ -390,7 +390,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
- "**Note:** In the above plot, the numerical solution is given discrete points connected by lines, while the analytical solution is drawn as a line. A helpful convention is to plot discrete data such as numerical solutions or measured data as points and lines while analytical solutions are drawn as lines. \n",
+ "**Note:** In the above plot, the numerical solution is given at discrete points connected by lines, while the analytical solution is drawn as a line. This is a helpful convention. We plot discrete data such as numerical solutions or measured data as points and lines while analytical solutions are drawn as lines. \n",
"\n",
"## Exercise\n",
"\n",
@@ -1035,30 +1035,29 @@
" c. Use a growth rate of $k_g=0.013$ [1/years] and compare the analytical solution (use initial condition p(1900) = 1578000000) to the Euler integration for time steps of 20 years from 1900 to 2020 (Hint: use method (1)- plot the two solutions together with the given data) \n",
" \n",
" d. Discussion question: If you decrease the time steps further and the solution converges, will it converge to the actual world population? Why or why not? \n",
- "\n"
+ "\n",
+ "**Note: We have used a new function `np.loadtxt` here. Use the `help` or `?` to learn about what this function does and how the arguments can change the output. In the next module, we will go into more details on how to load data, plot data, and present trends.**"
]
},
{
"cell_type": "code",
- "execution_count": 2,
+ "execution_count": 12,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
- " year population\n",
- "0 1900 1578000000\n",
- "1 1950 2526000000\n",
- "2 2000 6127000000\n",
- "3 2020 7795482000\n"
+ "years= [1900. 1950. 2000. 2020.]\n",
+ "population = [1.578000e+09 2.526000e+09 6.127000e+09 7.795482e+09]\n"
]
}
],
"source": [
- "import pandas as pd\n",
- "data = pd.read_csv('../data/world_population_1900-2020.csv')\n",
- "print(data)"
+ "import numpy as np\n",
+ "year,pop=np.loadtxt('../data/world_population_1900-2020.csv',skiprows=1,delimiter=',',unpack=True)\n",
+ "print('years=',year)\n",
+ "print('population =', pop)"
]
},
{