Skip to content

Commit

Permalink
Make example with orbit around Sun working
Browse files Browse the repository at this point in the history
  • Loading branch information
GregoireHENRY committed Apr 5, 2024
1 parent 4b82c78 commit fe63481
Show file tree
Hide file tree
Showing 14 changed files with 195 additions and 53 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "kalast"
version = "0.4.4-beta"
version = "0.5.1"
authors = ["Grégoire Henry <gregoire.henry@oma.be>"]
edition = "2021"
description = "Thermophysical Model for Binary Asteroids"
Expand Down
File renamed without changes.
File renamed without changes.
65 changes: 30 additions & 35 deletions cfg/cfg.toml
Original file line number Diff line number Diff line change
@@ -1,54 +1,49 @@
[window]
colormap = { name = "inferno", vmax = 400.0, scalar = "temperature" }
# export_frames = true
# high_dpi = true
# width = 1024
# height = 768
width = 1024
height = 768

[simulation]
routines = "thermal"
step = 200
duration = 31708800
step = 600
duration = 41071560

[simulation.export]
step = 200
duration = 172800
period = 1728000
cooldown_start = 31536000
# Annual period: 474.7286379896793 days = 41016554.322308294 s
# rounded up to 60: 41016600 s
# Spin period: 7.63262 h = 27477.432 s
# 2 periods: 54954.86 s
# rounded up to 60: 54960 s
# (474.7286379896793 * 24 + 2 * 7.63262) * 3600 = 41071509.186308295 s
# rounded up to 60: 41071560 s

# 1728000 = 20 days
# 1900800 = 22 days
# 31536000 = 365 days
# 31708800 = 367 days
# 94608000 = 365*3 days
# 94780800 = 365*3+2 days
[simulation.export]
step = 60
duration = 54960
period = 41071560
cooldown_start = 41016600

[scene]
sun.position.cartesian = [149597870.7, 0, 0]
camera.position.cartesian = [5, 0, 0]
sun.position = "origin"
camera.position.cartesian = [0, -15, 0]
camera.projection.perspective = 5.0

[[bodies]]
name = "Simple"
name = "RYUGU"
mesh.shape.path = "/Users/gregoireh/data/meshes/ryugu/SHAPE_SFM_49k_v20180804.obj"
interior.grid1d.linear = { size = 40, a = 2e-2 }
spin = { period = 27477.432, obliquity = 171 }
temperature.scalar = 150
color = "data"
# interior.grid1d.increasing = { skin = "one", m = 10, n = 5, b = 20 }
interior.grid1d.linear = { size = 24, a = 0.02403418 }
record = { columns = [0], mesh = true, depth = true }
spin = { period = 86400 }
temperature.scalar = 1

[bodies.mesh]
shape.shape = "triangle"
position = [0.0, -0.3333, 0.3333]

# 1) Identity
# 2 to 3) Rotation 90° around X and Y axis
# orientation = [1, 0, 0, 0, 1, 0, 0, 0, 1]
# orientation = [1, 0, 0, 0, 0, 1, 0, -1, 0]
orientation = [0, 0, -1, 0, 1, 0, 1, 0, 0]
record = { rows = [0], columns = [0], mesh = true, depth = true }

[bodies.material]
albedo = 0.1
emissivity = 0.9
thermal_inertia = 500.0
density = 2000.0
density = 2100.0
heat_capacity = 600.0

[bodies.state.orbit]
a = 1.190962269512474
e = 0.1910200912732423
File renamed without changes.
33 changes: 33 additions & 0 deletions examples/hayabusa2/cfg/cfg.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
[window]
ambient = [0.06, 0.06, 0.06]
export_frames = true
width = 328
height = 248

[spice]
kernel = "/Users/gregoireh/data/spice/hayabusa2/mk/hyb2_v03.tm"
frame = "HAYABUSA2_TIR-S"
origin = "RYUGU"

[simulation]
start = "2018-08-01 21:41:21"

[scene]
sun.position = "spice"

[scene.camera]
name = "HAYABUSA2"
position = "spice"
up = [0, -1, 0]
direction.vector = [0, 0, 1]
projection.perspective = 0.220958683 # 12.66° FOVY

[[bodies]]
name = "RYUGU"
frame = "RYUGU_FIXED"
state = "spice"
material.albedo = 0.1

# /Users/gregoireh/data/meshes/ryugu/SHAPE_SPC_3M_v20190328.obj
mesh.shape.path = "/Users/gregoireh/data/meshes/ryugu/SHAPE_SFM_49k_v20180804.obj"

Binary file modified examples/hayabusa2/screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
49 changes: 49 additions & 0 deletions examples/ryugu-thermal/cfg/cfg.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
[window]
colormap = { name = "inferno", vmax = 400.0, scalar = "temperature" }
# export_frames = true
width = 1024
height = 768

[simulation]
routines = "thermal"
step = 600
duration = 41071560

# Annual period: 474.7286379896793 days = 41016554.322308294 s
# rounded up to 60: 41016600 s
# Spin period: 7.63262 h = 27477.432 s
# 2 periods: 54954.86 s
# rounded up to 60: 54960 s
# (474.7286379896793 * 24 + 2 * 7.63262) * 3600 = 41071509.186308295 s
# rounded up to 60: 41071560 s

[simulation.export]
step = 60
duration = 54960
period = 41071560
cooldown_start = 41016600

[scene]
sun.position = "origin"
camera.position.cartesian = [0, -15, 0]
camera.projection.perspective = 5.0

[[bodies]]
name = "RYUGU"
mesh.shape.path = "/Users/gregoireh/data/meshes/ryugu/SHAPE_SFM_49k_v20180804.obj"
interior.grid1d.linear = { size = 40, a = 2e-2 }
spin = { period = 27477.432, obliquity = 171 }
temperature.scalar = 150
color = "data"
record = { rows = [0], columns = [0], mesh = true, depth = true }

[bodies.material]
albedo = 0.1
emissivity = 0.9
thermal_inertia = 500.0
density = 2100.0
heat_capacity = 600.0

[bodies.state.orbit]
a = 1.190962269512474
e = 0.1910200912732423
52 changes: 52 additions & 0 deletions examples/ryugu-thermal/cfg/spice.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
[window]
colormap = { name = "inferno", vmax = 400.0, scalar = "temperature" }
# export_frames = true
width = 1024
height = 768

[spice]
kernel = "/Users/gregoireh/data/spice/hayabusa2/mk/hyb2_v03.tm"
frame = "ECLIPJ2000"
origin = "RYUGU"

[simulation]
routines = "thermal"
start = "2021-01-05 00:00"
step = 600
duration = 41071560

# Annual period: 474.7286379896793 days
# or 41016554.322308294 s
# rounded up to 60: 41016600 s
# Spin period: 7.63262 h
# 2 periods: 54954.86 s
# rounded up to 60: 54960 s
# (474.7286379896793 * 24 + 2 * 7.63262) * 3600 = 41071509.186308295 s
# rounded up to 60: 41071560 s

[simulation.export]
step = 60
duration = 54960
period = 41071560
cooldown_start = 41016600

[scene]
sun.position = "spice"
camera.position.cartesian = [5.0, 0.0, 0.0]
camera.projection.perspective = 0.08726646259971647

[[bodies]]
name = "RYUGU"
color = "data"
state = "spice"
mesh.shape.path = "/Users/gregoireh/data/meshes/ryugu/SHAPE_SFM_49k_v20180804.obj"
interior.grid1d.linear = { size = 40, a = 2e-2 }
temperature.scalar = 150
record = { rows = [0], columns = [0], mesh = true, depth = true }

[bodies.material]
albedo = 0.1
emissivity = 0.9
thermal_inertia = 500.0
density = 2100.0
heat_capacity = 600.0
3 changes: 2 additions & 1 deletion preferences.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
[preferences]
touchpad_controls = true
no_window = true
# no_window = true

[preferences.debug]
config = true
general = true
window = false
thermal_stats = false
simulation = false
simulation_time = true
simulation_time_frequency = 1
39 changes: 25 additions & 14 deletions src/simu/routines/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use crate::{
find_ref_orbit, matrix_orientation_obliquity, matrix_spin, position_in_inertial_frame,
update_colormap_scalar,
util::*,
AirlessBody, BodyData, FoldersRun, Interior, MovementMode, Time, Window,
AirlessBody, BodyData, FoldersRun, Interior, MovementMode, ProjectionMode, Time, Window,
};

use downcast_rs::{impl_downcast, DowncastSync};
Expand Down Expand Up @@ -181,16 +181,18 @@ pub trait Routines: DowncastSync {
if let Some(body) = config.bodies.first() {
match &body.state {
State::Orbit(orbit) => match &orbit.frame {
FrameCenter::Sun => -position_in_inertial_frame(
orbit.a * AU,
orbit.e,
orbit.i * RPD,
orbit.node * RPD,
orbit.peri * RPD,
elapsed_from_start as Float,
orbit.tp,
MU_SUN,
),
FrameCenter::Sun => {
-position_in_inertial_frame(
orbit.a * AU,
orbit.e,
orbit.i * RPD,
orbit.node * RPD,
orbit.peri * RPD,
elapsed_from_start as Float,
orbit.tp,
MU_SUN,
) * 1e-3
}
FrameCenter::Body(_) => {
if time.iteration() == 0 {
println!("Warning: The Sun is set to be configured from the state of the primary body but only works if the state is an orbit centered on the Sun.");
Expand Down Expand Up @@ -347,7 +349,16 @@ pub trait Routines: DowncastSync {
};
scene.camera.up = config.scene.camera.up;
scene.camera.up_world = config.scene.camera.up;
scene.camera.projection = config.scene.camera.projection;
let mut projection = config.scene.camera.projection;

match &mut projection {
ProjectionMode::Perspective(fovy) => {
*fovy *= RPD;
}
_ => {}
}

scene.camera.projection = projection;

if let Some(near) = config.scene.camera.near {
scene.camera.near = Some(near);
Expand Down Expand Up @@ -438,8 +449,8 @@ pub trait Routines: DowncastSync {
elapsed_from_start as Float,
orbit.tp,
mu_ref,
);
matrix_translation = Mat4::new_translation(&(pos * 1e-3));
) * 1e-3;
matrix_translation = Mat4::new_translation(&pos);
}

match &orbit.frame {
Expand Down
1 change: 1 addition & 0 deletions src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ pub const ASTRONOMICAL_UNIT: Float = 1.495978707e11;

/// Alias to ASTRONOMICAL_UNIT.
pub const AU: Float = ASTRONOMICAL_UNIT;
pub const AU_KM: Float = AU * 1e-3;

/// [Solar flux constant](https://en.wikipedia.org/wiki/Solar_constant)
pub const SOLAR_CONSTANT: Float = 1361.0;
Expand Down
2 changes: 1 addition & 1 deletion src/win/camera.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub const POSITION: Vec3 = Vec3::new(5.0, 0.0, 0.0);
pub const ANCHOR: Vec3 = Vec3::new(0.0, 0.0, 0.0);
pub const NEAR_FACTOR: Float = 1e-5;
pub const FAR_FACTOR: Float = 2.0;
pub const FOVY: Float = 40.0 * RPD;
pub const FOVY: Float = 30.0;

pub const SENSITIVITY: Float = 1.0;
pub const SENSITIVITY_CORRECTION: Float = 1e-3;
Expand Down

0 comments on commit fe63481

Please sign in to comment.