$$
\newcommand{\uex}{{u_{\small\mbox{e}}}}
\newcommand{\tp}{\thinspace .}
$$
Making a module
- Previous programs: much repetitive code (esp.
solver
)
- DRY (Don't Repeat Yourself) principle: no copies of code
- A change needs to be done in one and only one place
- Module = just a file with functions (reused through
import
)
- Let's make a module by putting these functions in a file:
-
solver
-
verify_three_steps
-
verify_discrete_solution
-
explore
-
define_command_line_options
-
read_command_line
-
main
(with convergence rates)
-
verify_convergence_rate
Module name: decay_mod
, filename: decay_mod.py
.