-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
80 additions
and
425 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from rocket_twin.systems.control.clock import Clock | ||
|
||
__all__ = ['Clock'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from cosapp.base import System | ||
|
||
class Clock(System): | ||
|
||
def setup(self): | ||
|
||
#Transient to ensure the system is visited in every time step | ||
self.add_transient('x', der='1') | ||
self.add_outward('time_var', 0., desc="Command time") | ||
|
||
def compute(self): | ||
|
||
self.time_var = self.time |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import numpy as np | ||
from rocket_twin.systems import Clock | ||
from cosapp.drivers import RungeKutta | ||
|
||
class TestClock: | ||
|
||
def test_time(self): | ||
|
||
sys = Clock('sys') | ||
sys.add_driver(RungeKutta(order=4,time_interval=[0, 15], dt=1.)) | ||
sys.run_drivers() | ||
|
||
np.testing.assert_allclose(sys.time_var, 15., atol=10**(-4)) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import numpy as np | ||
from rocket_twin.systems import Station | ||
from cosapp.drivers import RungeKutta | ||
from cosapp.recorders import DataFrameRecorder | ||
|
||
class TestSequencesFMU: | ||
|
||
def test_sequence_fmu(self): | ||
|
||
sys = Station('sys', fmu_path="rocket_twin/systems/control/controller.fmu") | ||
driver = sys.add_driver(RungeKutta(order=4,time_interval=[0, 15], dt=0.01)) | ||
init = {'g_tank.weight_p' : 10., | ||
'rocket.tank.weight_p' : 0.} | ||
values = {'g_tank.w_out_max' : 1., | ||
'rocket.tank.w_out_max' : 0.5, | ||
'rocket.engine.force_max' : 100.} | ||
driver.set_scenario(init=init, values=values) | ||
driver.add_recorder(DataFrameRecorder(includes=['rocket.dyn.a']), period=1.) | ||
sys.run_drivers() | ||
|
||
data=driver.recorder.export_data() | ||
print(data) | ||
|
||
np.testing.assert_allclose(sys.rocket.dyn.a, 40., atol=10**(-1)) | ||
np.testing.assert_allclose(sys.g_tank.weight_p, 5., atol=10**(-2)) | ||
np.testing.assert_allclose(sys.rocket.tank.weight_p, 0., atol=10**(-2)) |
Binary file not shown.
Oops, something went wrong.