In this task the Haber-Bosch process will be simulated by using an ODE solver provided by the crate ode_solvers.
General:
- (advanced) Model a reaction system as ordinary differential equations (ODEs).
- (easy) Use a ODE-Solver to solve the ODEs. This simulate the reaction system.
- (advanced) Critically Investigate the results of the solver. What about units?
Rust:
- (easy) Implement and call functions in Rust to modularize your code in Rust.
- (easy) Implement, instantiate and 'dump' a data structure to the terminal.
- (advanced) Implement a
trait
of an external crate, here an solver for ODEs, to use it's functionality with custom types. - (advanced) Coarse Theory behind static type system and ownership
- Add dependency to ode_solvers (version 0.3.7) in
cargo.toml
- Either run
cargo add ode_solvers --vers 0.3.7
or editcargo.toml
directly - Run
cargo build
to let the dependencies be built in the background
- Either run
- In
main.rs
Implement a function that calculates reaction rates via the arrhenius equation- Call it and output the results.
- In
main.rs
add astruct
HaberBoschModel
that contains the model constants asf64
- Instantiate the struct and output the data by deriving the
Debug
trait.
- Instantiate the struct and output the data by deriving the
- Implement the
System
trait of the ode_solvers crate for theHaberBoschModel
struct- Therefore use the three concentration equations given in the video
- Instantiate the
Dop853
solver and use it to integrate the model- Output the
y_out
results to the command line - Use an
iterator
and sum the concentrations in each time step. - Compare your results with the solution given in the video
- Output the
As some of your starting your journey with Rust and this course cannot give an in-depth introduction but focuses and solving problems with Rust and on this way just provides enough detail, we want to make you aware of those three very good starter materials:
- The Rust Book - Gives an introduction suitable for people who have experiences in other coding languages.
- Rust By Examlpe - A collection of code examples with short explanations similiar to the
hints.rs
files you find in this course. - Rustlings - A project containing small Rust exercises and let you solve them in an interactive way. It follows the structure of the rust book.
Here you will appy, contents of Chapter 3, Chapter 5 and the advanced conept of traits explained in Chapter 10.2.
Chapter 4 contains concepts unique to Rust and to understand the difference between Rust and other languages it is very important and exciting. So we recommend a read but it's fine to skip and be fine if you fully understood after first read through. Most do not.