Difference between revisions of "Modelling and scientific computing"

From Process Model Formulation and Solution: 3E4
Jump to navigation Jump to search
Line 56: Line 56:
import numpy as np
import numpy as np


help(np.finfo)         # Read what the np.finfo function does
help(np.finfo)   # Read what the np.finfo function does


f = np.float32         # single precision, 32-bit float, 4 bytes
f = np.float32   # single precision, 32-bit float, 4 bytes
f = np.float64         # double precision, 64-bit float, 8 bytes
f = np.float64   # double precision, 64-bit float, 8 bytes


print('machine precision = eps = %.10g' % np.finfo(f).eps)
print('machine precision = eps = %.10g' % np.finfo(f).eps)

Revision as of 21:30, 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)

Calculating relative error


Working with integers

Working with floats

Special numbers

Practice questions

  1. 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?
  2. Homework problem, similar to the case presented on slide 18, except
    • Use two inlet streams F1 and F2, and assume they are volumetric flow rates
    • An irreversible reaction occurs, A+3Br2C
    • The reaction rate for A = rA=kCACB3
    1. Derive the time-varying component mass balance for species B.
      • VdCBdt=F1inCB,1in+F2inCB,2inFoutCB+03kCACB3V
    2. What is the steady state value of CB? Can it be calculated without knowing the steady state value of CA?
      • F1inCB,1in+F2inCB,2inFoutCB3kCACB3V - we require the steady state value of CA, denoted as CA, to calculate CB.

More exercises available here