kalast 0.2.0

Thermophysical model for binary systems of asteroids
Documentation

kalast

logo image

crate badge doc badge license badge pre-commit badge

Thermophysical model for binary systems of asteroids


Demo | In Action | Installation | If you clone this repo | License


Demo

demo screencast

In action

Computation of the temperature of a single point at the surface of an asteroid (initialized as sub-solar-point):

// src/main.rs

fn main() {
    // Initialize the library.
    let mut kalast = kalast::init();

    // System center of mass position.
    kalast.set_system_position(-kalast::V3::new(1.0, 0.0, 0.0) * kalast::ASTRONAUMICAL_UNIT * 1.1);

    // Add a body to the system without a mesh.
    kalast.add_body(
        "Asteroid",          // name
        kalast::V3::zeros(), // relative position to center of mass
        kalast::Properties::new(
            11.92 * kalast::HOUR, // rotation period
            11.92 * kalast::HOUR, // revolution period
            0.,                   // obliquity
            500.,                 // thermal inertia
            2146.,                // density
            600.,                 // heat capacity
            0.07,                 // albedo
            0.9,                  // emissivity
        ),
        None, // path to 3D mesh
    );

    // Create one facet located centered in longitude=latitude=0° of 2 m².
    kalast
        .get_target_mut()
        .new_face(kalast::M3::from_column_slice(&[
            100.0,      // vertex 1 x
            -2.0 / 3.0, //          y
            2.0 / 3.0,  //          z
            100.0,      // vertex 2 x
            -2.0 / 3.0, //          y
            -4.0 / 3.0, //          z
            100.0,      // vertex 3 x
            4.0 / 3.0,  //          y
            2.0 / 3.0,  //          z
        ]));

    // Some configurations about the system.
    kalast.enable_self_heating(false);

    // Set simulation duration and time step.
    kalast.set_time_with_revolution_target(30.0, 10.0 * kalast::MINUTE);

    // Start the simulation.
    kalast.start();

    println!("{}", kalast.get_target().surface_temperatures());
}

Installation

Get Rust:

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

Create a new Rust project:

# Move to the directory of your choice and create a project
cargo new my_project

# Move inside your project
cd my_project

Add the dependency kalast to your Cargo.toml:

...
[dependencies]
kalast = "0.2.0"

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.py [OPTIONS] COMMAND [ARGS]...

  Rust Project Builder Assistant.

  By default, compile the binary from the main program in debug mode, and
  run it. If you want to compile in release mode, for the main command or
  any subcommand, use the release option.

Options:
  -v, --version  Show version.
  -r, --release  Enable release mode.
  -h, --help     Show this message and exit.

Commands:
  doc              Build documentation.
  example          Compile and run an example.
  publish          Publish your library on crates.io.
  tests            Compile and execute unit and integration tests.
  update-versions  Update versions in all files according to the manifest.

Some examples:

# Compile and run src/main.rs in debug mode
./compile.py
# Compile and run src/main.rs in release mode
./compile.py -r
# Compile and run examples/spheres_mutual.rs in release mode
./compile.sh -r example spheres_mutual
# Execute all unit and integration tests
./compile.sh tests -a

This compile script requires few dependencies:

dotmap=*
envtoml=*
pathlib=*
subprocess=*
termcolor=*
typing=*
re=*

But if you want to compile yourself, follow this link.

Do not forget to work on a development branch:

# To create the branch.
git checkout -b dev

The projet uses pre-commit to prevent mistakes before commits. To install the hook scripts:

pre-commit install

A hook script uses an external tool called embedme to ensure the demo code displayed in the section In action matches automatically the code in src/main.rs without having to copy paste it.

License

Licensed under the Apache License, Version 2.0.