kalast
Thermophysical model for binary systems of asteroids
Demo |
In Action |
Installation |
License
Demo
In action
Computation of the temperature of a single point at the surface of an asteroid (initialized as sub-solar-point):
use kalast::{
EnvironmentSystem, Properties, SingleBody, Time, World, ASTRONAUMICAL_UNIT, HOUR, M3, MINUTE,
V3,
};
fn main() {
kalast::log_init!();
let mut asteroid = SingleBody::empty_object(
"Dimorphos", -V3::new(1.0, 0.0, 0.0) * ASTRONAUMICAL_UNIT * 1.074, Properties::new(
11.92 * HOUR, 11.92 * HOUR, 0., 500.0, 2146.0, 600.0, 0.07, 0.9, ),
);
asteroid.body_mut().new_face(&M3::from_column_slice(&[
1.0, -2. / 3., 2. / 3., 1.0, -2.0 / 3., -4. / 3., 1.0, 4. / 3., 2. / 3., ]));
asteroid.complete_model(false);
let time = Time::new(
10.0 * asteroid.body().properties.revolution_period(), 10.0 * MINUTE, );
let mut world = World::new(time, asteroid);
world.start();
world.save_daily("rsc/data/tmp.txt");
println!(
"min: {:.2}, max: {:.2}",
world.environment_system.body().surface_temperatures()[0],
world.environment_system.body().deepest_temperatures()[0]
);
let ground = world
.environment_system
.body()
.properties
.ground_vector()
.as_slice();
let temperatures = world
.environment_system
.body()
.ground_temperatures()
.as_slice();
let graph = kalast::Graph::new(1, 1);
graph.set_title("Daily ground temperatures");
graph.set_xlabel(0, "Depth [m]");
graph.set_ylabel(0, "Temperature [K]");
graph.set_axis_limits(0, Some(0.), Some(1.1), Some(260.), Some(360.));
graph.set_legend_title(0, "Hour angle [deg]");
graph.plot(
0,
kalast::args!(graph.py(), ground, temperatures),
kalast::kwargs!(graph.py(), ("label", "0")),
);
graph.save("rsc/img/tmp.svg", None);
graph.show(true);
}
Installation
Get Rust:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
Create a new Rust project:
cargo new my_project
cd my_project
Add the dependency kalast to your Cargo.toml
:
...
[dependencies]
kalast = "0.1.9"
To get a working code:
- copy to your
src/main.rs
either the code above or one from the examples
- get the necessary 3D object files
- make sure the paths to your 3D file are correct
- build and run your
src/main.rs
from the root of your project with:
cargo run --release
If you clone this repo
To build and run the program, tests or examples:
Usage: ./compile.sh [OPTIONS]
-r, --release build in release, default is debug
-e, --example [NAME] run the example [NAME]
-t, --test launch fast tests
--all-targets to be used with -t, runs all tests
You can also change the environment variable CUSTOM_RUSTFLAGS
inside the script to customize
compilation options (such as ignoring dead_code
).
Some examples:
./compile.sh
./compile.sh -r
./compile.sh -re spheres_mutual.rs
./compile.sh -t --all-targets
License
Licensed under the Apache License, Version 2.0.