Physics 212, 2018: Lectures 4
Back to the main Teaching page.
Back to Physics 212, 2018: Computational Modeling.
In this lecture, we continue learning the basics of computational modeling and Python language using the simple linear (,malthusian) growth model.
Contents
Finishing up from the previous lecture
- Your work
- explore how the solution spends on dt. Output results only when t is an integer.
New Python constructions
- Objects -- mutable (arrays and lists) vs. immutable (numbers)
- Object attributes and object methods, using dir()
- Overloading methods
- Variables vs. objects
- Lists vs. Numpy arrays
- Why np.zeros((2,4)) and not np.zeros(2,4)?
- Creation, concatenation (stacking).
- Slicing -- doesn't create new arrays
- Flatten copies data, ravel and reshape does not
- Strings
- Loops
- Vector math is always faster than element-by-element math
Basic plotting
- Section 3.3.1
- Malthusian growth with a loop and with plotting
- Your work
- plot sin(x) for x between 0 and pi. Only plot the positive part of the vertical axis. Label axes.
Our simplest model
A real environment won't have resources that are capable of supporting an infinite bacterial population. Thus as the population grows, the growth rate should decrease. The simplest assumption is that it decreases linearly . This gives for the growth: . Or, in other words, , where is the carrying capacity -- the number of bacteria where there growth rate is equal to 0, and the population stabilizes.