[![logo image]][doc link]

<p align="center">
    <a href="https://crates.io/crates/kalast">
        <img src="https://meritbadge.herokuapp.com/kalast?style=flat-square">
    </a>
    <a href="https://docs.rs/kalast">
        <img src="https://docs.rs/kalast/badge.svg">
    </a>
    <a href="https://opensource.org/licenses/Apache-2.0">
        <img src="https://img.shields.io/badge/License-Apache%202.0-blue.svg">
    </a>
</p>

# kalast

> Thermophysical model for binary systems of asteroids

-----

## Demo

[![asciicast image]][asciicast link]

## In action 

Single asteroid surface temperatures computations:

```rust
use kalast::{Body, Properties, Time, World, ASTRONAUMICAL_UNIT, HOUR, TAU, V3};
use std::path::Path;

fn main() {
    // Instanciate a celestial body named 'Dimorphos', at a distance of 1.664 AU from
    // the Sun, from a 3D object shape model located at 'rsc/obj/dimorphos.obj',
    // with a complete set of ground physical properties.
    let mut body = Body::new(
        "Dimorphos",
        V3::new(0.0, 1.0, 0.0) * ASTRONAUMICAL_UNIT * 1.664,
        Path::new("rsc/obj/dimorphos.obj"),
        Properties::new(
            11.92 * HOUR,        // rotation period
            11.92 * HOUR,        // revolution period
            162.0 * TAU / 360.0, // obliquity
            500.0,               // thermal inertia
            2146.0,              // density
            600.0,               // heat capacity
            0.07,                // albedo
            0.9,                 // emissivity
        ),
    );
    body.set_faces_mask_equator(); // only computes temperatures for equator

    // Create a simulation time that lasts 50 revolution period of the body with 30 seconds steps.
    // The residual 0.75 period is for the last frame to be at noon (max temperature peek at
    // longitude=0°, according to this initial bodies setup).
    let time = Time::new(50.75 * body.properties.revolution_period(), 30.0);

    let mut world = World::new(time, body, None); // define the world of the simulation
    world.start(); // run the simulation
    world.save(Path::new("rsc/temperatures/dimorphos_equator.txt")); // save the temperatures to a file
}
```

## Build source

```sh
# build as a release
./compile.sh -r

# run
./kalast
```

## TODO

+ [ ] mutual heating from primary/moon
+ [ ] self heating
+ [ ] validation
+ [ ] finit diff, FEM, 2D/3D convection
+ [ ] mutual occultations
+ [ ] shadowing

<br>

#### License

<sub>
Licensed under the <a href="LICENSE">Apache License, Version 2.0</a>.
</sub>

[logo image]: https://gitlab-as.oma.be/gregoireh/kalast/-/raw/main/rsc/img/SBMT-dimorphos.png
[crate link]: https://crates.io/crates/kalast
[crate badge]: https://meritbadge.herokuapp.com/kalast?style=flat-square
[doc link]: https://docs.rs/kalast
[doc badge]: https://docs.rs/kalast/badge.svg
[license link]: https://opensource.org/licenses/Apache-2.0
[license badge]: https://img.shields.io/badge/License-Apache%202.0-blue.svg
[asciicast image]: https://asciinema.org/a/fUfasjvJEvFUNTux6KOj5IA9Q.png
[asciicast link]: https://asciinema.org/a/fUfasjvJEvFUNTux6KOj5IA9Q?speed=5&autoplay=1&loop=1
