Difference between revisions of "Modelling and scientific computing"
Jump to navigation
Jump to search
Line 80: | Line 80: | ||
# Infinities | # Infinities | ||
print(np.inf, -np.inf) | print(np.inf, -np.inf) | ||
# inf, number exceeds maximum value that | |||
print(np.inf * -4.0) | # is possible with a 64-bit float: overflow | ||
print(np.float(1E400)) | |||
print(np.inf * -4.0) # -inf | |||
print(np.divide(2.4, 0.0)) # inf | print(np.divide(2.4, 0.0)) # inf | ||
Line 98: | Line 101: | ||
eps = np.finfo(np.float).eps | eps = np.finfo(np.float).eps | ||
e = eps/3.0 | |||
# Create a number smaller than machine precision | |||
e = eps/3.0 | |||
# Question: why can we create a number smaller than eps? | # Question: why can we create a number smaller than eps? | ||
print(e) | print(e) | ||
Line 105: | Line 110: | ||
# when working with values smaller than eps. Why? | # when working with values smaller than eps. Why? | ||
# The print out here should "True", but it prints "False" | # The print out here should "True", but it prints "False" | ||
print((1.0 + (e + e)) == (1.0 + e + e)) | print((1.0 + (e + e)) == (1.0 + e + e)) | ||
</code> | </code> | ||
</div></html> | </div></html> |
Latest revision as of 21:31, 14 January 2019
Process modelling slides
Please download the lecture slides. 13 September 2010 (slides 1 to 8)
15 September 2010 (slides 9 to 15)
16 September 2010 (slides 16 to 19)
20 September 2010 (slides 20 to the end)
Approximation and computer representation
Please download the lecture slides. 22 and 23 September (updated)
- More about the Ariane 5 rocket 16-bit overflow
- Python code used in class for ...
Calculating relative error
Working with integers
Working with floats
Special numbers
Practice questions
- From the Hangos and Cameron reference, (available here] - accessible from McMaster computers only)
- Work through example 2.4.1 on page 33
- Exercise A 2.1 and A 2.2 on page 37
- Exercise A 2.4: which controlling mechanisms would you consider?
- Homework problem, similar to the case presented on slide 18, except
- Use two inlet streams \(\sf F_1\) and \(\sf F_2\), and assume they are volumetric flow rates
- An irreversible reaction occurs, \(\sf A + 3B \stackrel{r}{\rightarrow} 2C\)
- The reaction rate for A = \(\sf -r_A = -kC_\text{A} C_\text{B}^3\)
- Derive the time-varying component mass balance for species B.
- \( V\frac{dC_B}{dt} = F^{\rm in}_1 C^{\rm in}_{\sf B,1} + F^{\rm in}_2 C^{\rm in}_{\sf B,2} - F^{\rm out} C_{\sf B} + 0 - 3 kC_{\sf A} C_{\sf B}^3 V \)
- What is the steady state value of \(\sf C_B\)? Can it be calculated without knowing the steady state value of \(\sf C_A\)?
- \( F^{\rm in}_1 C^{\rm in}_{\sf B,1} + F^{\rm in}_2 C^{\rm in}_{\sf B,2} - F^{\rm out} \overline{C}_{\sf B} - 3 k \overline{C}_{\sf A} \overline{C}^3_{\sf B} V \) - we require the steady state value of \(C_{\sf A}\), denoted as \(\overline{C}_{\sf A}\), to calculate \(\overline{C}_{\sf B}\).