diff --git a/rocket_twin/drivers/fuelling_rocket.py b/rocket_twin/drivers/fuelling_rocket.py index 1370d25..751ebc8 100644 --- a/rocket_twin/drivers/fuelling_rocket.py +++ b/rocket_twin/drivers/fuelling_rocket.py @@ -6,7 +6,7 @@ class FuellingRocket(Driver): - def __init__(self, name: str, flux, dt, owner: Optional["System"] = None, **kwargs): + def __init__(self, name: str, w_out, dt, owner: Optional["System"] = None, **kwargs): super().__init__(name, owner, **kwargs) # Fueling: @@ -17,16 +17,16 @@ def __init__(self, name: str, flux, dt, owner: Optional["System"] = None, **kwar init = { "rocket.dyn.switch": False, - "rocket.tank.flux": 0.0, - "g_tank.p_in": 0.0, - "g_tank.flux": flux, + "rocket.tank.w_out_temp": 0.0, + "g_tank.w_in": 0.0, + "g_tank.w_out_temp": w_out, } - stop = "rocket.tank.w_p >= rocket.tank.w_max" + stop = "rocket.tank.weight_p >= rocket.tank.weight_max" self.rk.set_scenario(init=init, stop=stop) self.rk.add_recorder( - DataFrameRecorder(includes=["rocket.dyn.a", "g_tank.w", "rocket.tank.w_p"], hold=True), + DataFrameRecorder(includes=["rocket.dyn.a", "g_tank.weight", "rocket.tank.weight_p"], hold=True), period=dt, ) self.data = None diff --git a/rocket_twin/drivers/mission.py b/rocket_twin/drivers/mission.py index 411a859..c1007bd 100644 --- a/rocket_twin/drivers/mission.py +++ b/rocket_twin/drivers/mission.py @@ -10,15 +10,15 @@ class Mission(Driver): def __init__( - self, name: str, flux_in, flux_out, dt, owner: Optional["System"] = None, **kwargs + self, name: str, w_in, w_out, dt, owner: Optional["System"] = None, **kwargs ): super().__init__(name, owner, **kwargs) # Fuelling - self.add_child(FuellingRocket("fuelling", flux=flux_in, dt=dt, owner=owner)) + self.add_child(FuellingRocket("fuelling", w_out=w_in, dt=dt, owner=owner)) # Flying - self.add_child(VerticalFlyingRocket("flying", flux=flux_out, dt=dt, owner=owner)) + self.add_child(VerticalFlyingRocket("flying", w_out=w_out, dt=dt, owner=owner)) # Recorder self.data = None diff --git a/rocket_twin/drivers/vertical_flying_rocket.py b/rocket_twin/drivers/vertical_flying_rocket.py index a031956..115bf27 100644 --- a/rocket_twin/drivers/vertical_flying_rocket.py +++ b/rocket_twin/drivers/vertical_flying_rocket.py @@ -6,7 +6,7 @@ class VerticalFlyingRocket(Driver): - def __init__(self, name: str, flux, dt, owner: Optional["System"] = None, **kwargs): + def __init__(self, name: str, w_out, dt, owner: Optional["System"] = None, **kwargs): super().__init__(name, owner, **kwargs) # Fueling: @@ -17,16 +17,16 @@ def __init__(self, name: str, flux, dt, owner: Optional["System"] = None, **kwar init = { "rocket.dyn.switch": True, - "g_tank.p_in": 0.0, - "g_tank.flux": 0.0, - "rocket.tank.flux": flux, + "g_tank.w_in": 0.0, + "g_tank.w_out_temp": 0.0, + "rocket.tank.w_out_temp": w_out, } - stop = "rocket.tank.w_p <= 0." + stop = "rocket.tank.weight_p <= 0." self.rk.set_scenario(init=init, stop=stop) self.rk.add_recorder( - DataFrameRecorder(includes=["rocket.dyn.a", "g_tank.w", "rocket.tank.w_p"], hold=True), + DataFrameRecorder(includes=["rocket.dyn.a", "g_tank.weight", "rocket.tank.weight_p"], hold=True), period=dt, ) self.data = None diff --git a/rocket_twin/notebooks/Visualisation.ipynb b/rocket_twin/notebooks/Visualisation.ipynb index 188320e..d67dbac 100644 --- a/rocket_twin/notebooks/Visualisation.ipynb +++ b/rocket_twin/notebooks/Visualisation.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "code", - "execution_count": 1, + "execution_count": null, "id": "8bec8444-0001-4e4a-bb3a-aae9574a5cb6", "metadata": {}, "outputs": [], @@ -12,7 +12,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": null, "id": "97e7cc0c-c54d-4dac-9966-ac30c44abe14", "metadata": {}, "outputs": [], @@ -22,41 +22,10 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": null, "id": "3b5aeda9-94d7-4f2d-a28c-c9e168cb4e69", "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "\n", - " \n", - " " - ], - "text/markdown": [ - "\n", - "### Child components\n", - "\n", - "- `pipe`: Pipe\n", - "- `g_tank`: Tank\n", - "- `rocket`: Rocket" - ], - "text/plain": [ - "ground - Ground" - ] - }, - "execution_count": 3, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "ground" ] diff --git a/rocket_twin/systems/ground.py b/rocket_twin/systems/ground.py index 786d4c9..ebda172 100644 --- a/rocket_twin/systems/ground.py +++ b/rocket_twin/systems/ground.py @@ -9,23 +9,15 @@ def setup(self): self.add_child(Pipe("pipe")) self.add_child(Tank("g_tank")) - self.connect(self.g_tank.outwards, self.pipe.inwards, {'p_out' : 'p_in'}) - self.connect(self.pipe.outwards, self.rocket.inwards, {'p_out' : 'p_in'}) + self.connect(self.g_tank.outwards, self.pipe.inwards, {'w_out' : 'w_in'}) + self.connect(self.pipe.outwards, self.rocket.inwards, {'w_out' : 'w_in'}) - self.g_tank.w_max = 10. - self.rocket.tank.w_p = 0. + self.g_tank.weight_max = 10. + self.rocket.tank.weight_p = 0. self.exec_order = ["pipe", "g_tank", "rocket"] #Design methods dm = self.add_design_method('start') - dm.add_unknown('g_tank.w_p') - dm.add_equation('g_tank.w_p == g_tank.w_max') - - #dm = self.add_design_method('fuel') - #dm.add_unknown('pipe.p') - #dm.add_target('rocket.tank.w_p') - - #dm = self.add_design_method('flight') - #dm.add_unknown('rocket.tank.p_out') - #dm.add_target('rocket.tank.w_p') + dm.add_unknown('g_tank.weight_p') + dm.add_equation('g_tank.weight_p == g_tank.weight_max') diff --git a/rocket_twin/systems/rocket/rocket.py b/rocket_twin/systems/rocket/rocket.py index 89226d4..891f23e 100644 --- a/rocket_twin/systems/rocket/rocket.py +++ b/rocket_twin/systems/rocket/rocket.py @@ -7,7 +7,7 @@ class Rocket(System): def setup(self): self.add_child(Engine("engine")) - self.add_child(Tank("tank"), pulling=["p_in"]) + self.add_child(Tank("tank"), pulling=["w_in"]) self.add_child( RocketGeom("geom", centers=["engine", "tank"], weights=["weight_eng", "weight_tank"]) ) diff --git a/rocket_twin/systems/tank/pipe.py b/rocket_twin/systems/tank/pipe.py index 9e911a7..7e4b6f8 100644 --- a/rocket_twin/systems/tank/pipe.py +++ b/rocket_twin/systems/tank/pipe.py @@ -4,8 +4,8 @@ class Pipe(System): def setup(self): - self.add_inward("p_in", 0.0, desc="Fuel income rate", unit="kg/s") - self.add_outward("p_out", 0.0, desc="Fuel exit rate", unit="kg/s") + self.add_inward("w_in", 0.0, desc="Fuel income rate", unit="kg/s") + self.add_outward("w_out", 0.0, desc="Fuel exit rate", unit="kg/s") def compute(self): - self.p_out = self.p_in + self.w_out = self.w_in diff --git a/rocket_twin/systems/tank/tank.py b/rocket_twin/systems/tank/tank.py index 4ece7b0..17dd292 100644 --- a/rocket_twin/systems/tank/tank.py +++ b/rocket_twin/systems/tank/tank.py @@ -5,26 +5,26 @@ class Tank(System): def setup(self): #Geometry - self.add_inward("w_s", 1.0, desc="Structure weight", unit="kg") - self.add_inward("w_max", 5.0, desc="Maximum fuel capacity", unit="kg") + self.add_inward("weight_s", 1.0, desc="Structure weight", unit="kg") + self.add_inward("weight_max", 5.0, desc="Maximum fuel capacity", unit="kg") #Inputs - self.add_inward("p_in", 0.0, desc="Fuel income rate", unit="kg/s") + self.add_inward("w_in", 0.0, desc="Fuel income rate", unit="kg/s") #Flux control - self.add_inward('flux', 0., desc="Fuel output rate", unit='kg/s') + self.add_inward('w_out_temp', 0., desc="Fuel output rate", unit='kg/s') #Transient - self.add_outward("dp_dt", 0., desc="Fuel mass rate of change", unit="kg/s") - self.add_transient("w_p", der="dp_dt", desc="Propellant weight") + self.add_outward("dw_dt", 0., desc="Fuel mass rate of change", unit="kg/s") + self.add_transient("weight_p", der="dw_dt", desc="Propellant weight") #Outputs self.add_outward("weight", 1.0, desc="Weight", unit="kg") self.add_outward("cg", 1.0, desc="Center of gravity", unit="m") - self.add_outward("p_out", 0.0, desc="Fuel output rate", unit="kg/s") + self.add_outward("w_out", 0.0, desc="Fuel output rate", unit="kg/s") def compute(self): - self.p_out = self.flux - self.dp_dt = self.p_in - self.p_out - self.weight = self.w_s + self.w_p + self.w_out = self.w_out_temp + self.dw_dt = self.w_in - self.w_out + self.weight = self.weight_s + self.weight_p self.cg = 3.0 diff --git a/rocket_twin/tests/test_flying_rocket.py b/rocket_twin/tests/test_flying_rocket.py index c6bf0de..03ae24b 100644 --- a/rocket_twin/tests/test_flying_rocket.py +++ b/rocket_twin/tests/test_flying_rocket.py @@ -7,12 +7,12 @@ class TestVerticalFlyingRocket: def test_run_once(self): sys = Ground("sys") - sys.g_tank.w_p = 0.0 - sys.rocket.tank.w_p = sys.rocket.tank.w_max - flux = 3.0 + sys.g_tank.weight_p = 0.0 + sys.rocket.tank.weight_p = sys.rocket.tank.weight_max + w_out = 3.0 dt = 0.1 - sys.add_driver(VerticalFlyingRocket("vfr", flux=flux, dt=dt, owner=sys)) + sys.add_driver(VerticalFlyingRocket("vfr", w_out=w_out, dt=dt, owner=sys)) sys.run_drivers() @@ -20,8 +20,8 @@ def test_run_once(self): data = data.drop(["Section", "Status", "Error code"], axis=1) np.testing.assert_allclose(sys.rocket.dyn.a, 40.0, atol=10 ** (-10)) - np.testing.assert_allclose(sys.rocket.tank.w_p, 0.0, atol=10 ** (-10)) - np.testing.assert_allclose(sys.g_tank.w_p, 0.0, atol=10 ** (-10)) + np.testing.assert_allclose(sys.rocket.tank.weight_p, 0.0, atol=10 ** (-10)) + np.testing.assert_allclose(sys.g_tank.weight_p, 0.0, atol=10 ** (-10)) test_vfr = TestVerticalFlyingRocket() diff --git a/rocket_twin/tests/test_mission.py b/rocket_twin/tests/test_mission.py index 23da801..ab4eae1 100644 --- a/rocket_twin/tests/test_mission.py +++ b/rocket_twin/tests/test_mission.py @@ -7,13 +7,13 @@ class TestMission: def test_run_once(self): sys = Ground("sys") - sys.g_tank.w_p = sys.g_tank.w_max - sys.rocket.tank.w_p = 0.0 - flux_in = 3.0 - flux_out = 3.0 + sys.g_tank.weight_p = sys.g_tank.weight_max + sys.rocket.tank.weight_p = 0.0 + w_in = 3.0 + w_out = 3.0 dt = 0.1 - sys.add_driver(Mission("mission", flux_in=flux_in, flux_out=flux_out, dt=dt, owner=sys)) + sys.add_driver(Mission("mission", w_in=w_in, w_out=w_out, dt=dt, owner=sys)) sys.run_drivers() @@ -21,8 +21,8 @@ def test_run_once(self): data = data.drop(["Section", "Status", "Error code"], axis=1) np.testing.assert_allclose(sys.rocket.dyn.a, 40.0, atol=10 ** (-10)) - np.testing.assert_allclose(sys.rocket.tank.w_p, 0.0, atol=10 ** (-10)) - np.testing.assert_allclose(sys.g_tank.w_p, 5.0, atol=10 ** (-10)) + np.testing.assert_allclose(sys.rocket.tank.weight_p, 0.0, atol=10 ** (-10)) + np.testing.assert_allclose(sys.g_tank.weight_p, 5.0, atol=10 ** (-10)) test_mission = TestMission() diff --git a/rocket_twin/tests/test_refuel_rocket.py b/rocket_twin/tests/test_refuel_rocket.py index 96fbe57..fd6fbb6 100644 --- a/rocket_twin/tests/test_refuel_rocket.py +++ b/rocket_twin/tests/test_refuel_rocket.py @@ -7,12 +7,12 @@ class TestFuellingRocket: def test_run_once(self): sys = Ground("sys") - sys.g_tank.w_p = sys.g_tank.w_max - sys.rocket.tank.w_p = 0.0 - flux = 3.0 + sys.g_tank.weight_p = sys.g_tank.weight_max + sys.rocket.tank.weight_p = 0.0 + w_out = 3.0 dt = 0.1 - sys.add_driver(FuellingRocket("fr", flux=flux, dt=dt, owner=sys)) + sys.add_driver(FuellingRocket("fr", w_out=w_out, dt=dt, owner=sys)) sys.run_drivers() @@ -20,8 +20,8 @@ def test_run_once(self): data = data.drop(["Section", "Status", "Error code"], axis=1) np.testing.assert_allclose(sys.rocket.dyn.a, 0.0, atol=10 ** (-10)) - np.testing.assert_allclose(sys.rocket.tank.w_p, 5.0, atol=10 ** (-10)) - np.testing.assert_allclose(sys.g_tank.w_p, 5.0, atol=10 ** (-10)) + np.testing.assert_allclose(sys.rocket.tank.weight_p, 5.0, atol=10 ** (-10)) + np.testing.assert_allclose(sys.g_tank.weight_p, 5.0, atol=10 ** (-10)) test_fr = TestFuellingRocket() diff --git a/rocket_twin/tests/test_tank.py b/rocket_twin/tests/test_tank.py index 9f02915..bc9e0f4 100644 --- a/rocket_twin/tests/test_tank.py +++ b/rocket_twin/tests/test_tank.py @@ -10,7 +10,7 @@ def test_fuel(self): driver = sys.add_driver(RungeKutta(order=4, dt=0.1)) driver.time_interval = (0, 5) - init = {"p_in": 3.0, "flux": 0.0, "w_p": 0.0} + init = {"w_in": 3.0, "w_out_temp": 0.0, "weight_p": 0.0} driver.set_scenario(init=init) @@ -23,7 +23,7 @@ def test_flight(self): driver = sys.add_driver(RungeKutta(order=4, dt=0.1)) driver.time_interval = (0, 5) - init = {"p_in": 0.0, "flux": 3.0, "w_p": 15.0} + init = {"w_in": 0.0, "w_out_temp": 3.0, "weight_p": 15.0} driver.set_scenario(init=init)