-
Notifications
You must be signed in to change notification settings - Fork 6
/
thermal_model_test.py
61 lines (49 loc) · 2.02 KB
/
thermal_model_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
"""Simple test of the thermal model to see if temperatures evolve as expected"""
import pykep as pk
from test_utils import wait_for_activity
import paseos
from paseos import SpacecraftActor, ActorBuilder, load_default_cfg
import asyncio
import pytest
# tell pytest to create an event loop and execute the tests using the event loop
@pytest.mark.asyncio
async def test_thermal():
"""Test if performing activity changes temperature as expected"""
# Define central body
earth = pk.planet.jpl_lp("earth")
# Define local actor
sat1 = ActorBuilder.get_actor_scaffold("sat1", SpacecraftActor, pk.epoch(0))
ActorBuilder.set_orbit(sat1, [7000000, 0, 0], [0, 8000.0, 0], pk.epoch(0), earth)
ActorBuilder.set_power_devices(sat1, 50000, 1000000, 1000)
ActorBuilder.set_thermal_model(
actor=sat1,
actor_mass=50.0,
actor_initial_temperature_in_K=273.15,
actor_sun_absorptance=1.0,
actor_infrared_absorptance=1.0,
actor_sun_facing_area=1.0,
actor_central_body_facing_area=1.0,
actor_emissive_area=1.0,
actor_thermal_capacity=1000,
)
# init simulation
cfg = load_default_cfg() # loading cfg to modify defaults
cfg.sim.dt = 5.0 # setting higher timestep to run things quickly
cfg.sim.activity_timestep = 1.0
cfg.io.logging_interval = 10.0 # log every 0.25 seconds
cfg.sim.time_multiplier = 200.0 # speed up execution for convenience
sim = paseos.init_sim(sat1, cfg)
# Initial temperature is 0C / 273.15K
assert sat1.temperature_in_K == 273.15
async def func(args):
await asyncio.sleep(16.0)
# Register an activity that draws 10 watt per second
sim.register_activity("Activity_1", activity_function=func, power_consumption_in_watt=10)
# Run the activity
sim.perform_activity("Activity_1")
await wait_for_activity(sim)
assert sat1.temperature_in_K > 285
assert sat1.temperature_in_K < 300
sim.save_status_log_csv("thermal_test.csv")
if __name__ == "__main__":
test_thermal()