ChEn-3170: Computational Methods in Chemical Engineering Fall 2018 UMass Lowell; Prof. V. F. de Almeida 10Sep2018
A web application for presenting code, results, and discussion (analysis) all in one place. There are many sources to learn additional information from, such as:
this cell
)¶Have you seen this formula before?
\begin{equation} k = k_0 \, e^{-\frac{E_a}{RT}}. \end{equation}How about typesetting formula in text: $\ln k = \ln k_0 - \frac{E_a}{RT}$? How was this done?
All of this text was written in Jupyter Markdown markup language and rendered via executing this cell. If you double click on this cell, you will see the Markdown source file. Then execute Run
on the cell to render it again.
Jupyter Markdown markup language.
More on Jupyter Markdown markup language.
Additional on Jupyter Markdown markup language.
Useful extensions and colored boxes
Markdown project (see markdown render tool)
NB: you can export the notebook to different formats (Menu Bar: file -> Download as ->).
Here is a plotting example from the Matplotlib site:
import matplotlib.pyplot as plt # this is an import of the package
plt.plot([1,2,3,4])
plt.ylabel('some numbers')
plt.show()
this Python code will be executed in the next cell, the last line of source code will display the x-y plot.
import matplotlib.pyplot as plt
plt.plot([1,2,3,4])
plt.ylabel('some numbers')
plt.show()
Let's use another code plotting script:
import numpy as np
import matplotlib.pyplot as plt
def f(t):
return np.exp(-t) * np.cos(2*np.pi*t)
t1 = np.arange(0.0, 5.0, 0.1)
t2 = np.arange(0.0, 5.0, 0.02)
plt.figure(1)
plt.subplot(211)
plt.plot(t1, f(t1), 'bo', t2, f(t2), 'k')
plt.subplot(212)
plt.plot(t2, np.cos(2*np.pi*t2), 'r--')
plt.show()
and execute the next cell to obtain the plot below.
'''
This is an example of two stacked plots using
the subplot() method of the pyplot package.
'''
import numpy as np # import the numpy package for arrays computation
import matplotlib.pyplot as plt # import the matplotlib package for plotting
def f(t):
'''
Define a decaying cosine function
'''
return np.exp(-t) * np.cos(2*np.pi*t)
t1 = np.arange(0.0, 5.0, 0.1)
t2 = np.arange(0.0, 5.0, 0.02)
plt.figure(1)
plt.subplot(211)
plt.plot(t1, f(t1), 'bo', t2, f(t2), 'k')
plt.subplot(212)
plt.plot(t2, np.cos(2*np.pi*t2), 'r--')
plt.show()
print(type(t1))
print('t1 = ',t1)
f
function to access its docstring¶help(f)
plt.subplot(211)
mean? Use help to access documentation if any:¶help(plt.subplot)