예제 #1
0
class TestEOM6DOF(unittest.TestCase):
    def setUp(self) -> None:
        self.verification_module = EOM6DOFVerificationDataModule()
        self.simulation = Simulation(
            states_class=EOM6DOFStates,
            integrator=AB3Integrator(h=0.01, rk4=True, fd_max_order=1),
            modules=[EOM6DOF(), self.verification_module],
            logging=Logging(),
            initial_state_values=None,
        )

        verification_data_path = Path(
            __file__).parent / "eom6dof_verification_data.msgp.gz"
        self.verification_data = flex_load(verification_data_path)

    def test_eom6dof(self):
        self.simulation.initialize()
        self.verification_module.set_verification_data(
            self.verification_data[0])

        result = self.simulation.run(1000)

        state_names = ["vii", "xi", "omega_b"]
        for state_name in state_names:
            result[f"error_{state_name}"] = (result[state_name] -
                                             result[f"correct_{state_name}"])
            # / result[state_name] * 100

        plotter = Plotter()
        # plotter.plot(result)
        plotter.plot_to_pdf(
            Path(__file__).parent / "eom6dof_results.i.pdf", result)
        plt.show()
예제 #2
0
 def setUp(self) -> None:
     self.simulation = Simulation(
         states_class=FMAdderStates,
         integrator=AB3Integrator(h=0.01, rk4=True, fd_max_order=1),
         modules=[
             FMAdderTestModule(),
             FMAdder(),
         ],
         logging=Logging(),
         initial_state_values=None,
     )
예제 #3
0
    def setUp(self) -> None:
        self.verification_module = EOM6DOFVerificationDataModule()
        self.simulation = Simulation(
            states_class=EOM6DOFStates,
            integrator=AB3Integrator(h=0.01, rk4=True, fd_max_order=1),
            modules=[EOM6DOF(), self.verification_module],
            logging=Logging(),
            initial_state_values=None,
        )

        verification_data_path = Path(
            __file__).parent / "eom6dof_verification_data.msgp.gz"
        self.verification_data = flex_load(verification_data_path)
예제 #4
0
 def setUp(self) -> None:
     self.simulation = Simulation(
         states_class=VariableMassStates,
         integrator=AB3Integrator(h=0.01, rk4=True, fd_max_order=1),
         modules=[
             VariableMassTestModule(),
             VariableMass(
                 mass=(10, 5),
                 cg=([1, 0, 0], [0, 0, 0]),
                 inertia=(np.eye(3), np.zeros((3, 3))),
             ),
         ],
         logging=Logging(),
         initial_state_values=None,
     )
예제 #5
0
def main():
    simulation = Simulation(
        states_class=Sim1States,
        integrator=AB3Integrator(h=0.01, rk4=True, fd_max_order=1),
        modules=[
            ModuleA(),
            ModuleB(),
        ],
        logging=Logging(),
        initial_state_values=None,
    )

    simulation.initialize()

    with time_it("simulation run"):
        result = simulation.run(10000)

    plotter = Plotter()
    plotter.plot_to_pdf(Path(__file__).parent / "results.i.pdf", result)
예제 #6
0
class TestEOM6DOF(unittest.TestCase):
    def setUp(self) -> None:
        self.simulation = Simulation(
            states_class=FMAdderStates,
            integrator=AB3Integrator(h=0.01, rk4=True, fd_max_order=1),
            modules=[
                FMAdderTestModule(),
                FMAdder(),
            ],
            logging=Logging(),
            initial_state_values=None,
        )

    def test_fmadder(self):
        self.simulation.initialize()
        result = self.simulation.run(3)

        force_sum = result.force_0 + result.force_1 + result.force_2 - result.force_b
        self.assertTrue(np.all(np.isclose(force_sum.values, 0.0)))

        moment_sum = result.moment_0 + result.moment_1 + result.moment_2 - result.moment_b
        self.assertTrue(np.all(np.isclose(moment_sum.values, 0.0)))
예제 #7
0
class TestVariableMass(unittest.TestCase):
    def setUp(self) -> None:
        self.simulation = Simulation(
            states_class=VariableMassStates,
            integrator=AB3Integrator(h=0.01, rk4=True, fd_max_order=1),
            modules=[
                VariableMassTestModule(),
                VariableMass(
                    mass=(10, 5),
                    cg=([1, 0, 0], [0, 0, 0]),
                    inertia=(np.eye(3), np.zeros((3, 3))),
                ),
            ],
            logging=Logging(),
            initial_state_values=None,
        )

    def test_variable_mass(self):
        self.simulation.initialize()
        result = self.simulation.run(500)

        plotter = Plotter()
        plotter.plot_to_pdf(
            Path(__file__).parent / "variable_mass_results.i.pdf", result)