From 37d746c1ccd92f2008817653e4c88d80a8177291 Mon Sep 17 00:00:00 2001 From: TJStienstra Date: Fri, 1 Dec 2023 10:47:25 +0100 Subject: [PATCH] Adjust code to new BRiM and SymPy version --- examples/rolling_disc_optimization/model.py | 2 +- examples/whipple_bicycle_simulation/model.py | 2 +- examples/whipple_upper_rider_simulation/model.py | 2 +- tests/test_simulator.py | 5 +++-- utilities/simulator.py | 6 +++--- 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/examples/rolling_disc_optimization/model.py b/examples/rolling_disc_optimization/model.py index 2477621..6dfdde3 100644 --- a/examples/rolling_disc_optimization/model.py +++ b/examples/rolling_disc_optimization/model.py @@ -22,7 +22,7 @@ system = disc.to_system() normal = disc.ground.get_normal(disc.ground.origin) -system.apply_gravity(-g * normal) +system.apply_uniform_gravity(-g * normal) r_long = me.cross(normal, disc.disc.rotation_axis).normalize() system.add_loads( me.Torque( diff --git a/examples/whipple_bicycle_simulation/model.py b/examples/whipple_bicycle_simulation/model.py index 4359094..f1d73bd 100644 --- a/examples/whipple_bicycle_simulation/model.py +++ b/examples/whipple_bicycle_simulation/model.py @@ -42,7 +42,7 @@ # Apply additional forces and torques to the system g = symbols("g") -system.apply_gravity(-g * bicycle.ground.get_normal(bicycle.ground.origin)) +system.apply_uniform_gravity(-g * bicycle.ground.get_normal(bicycle.ground.origin)) steer_torque = dynamicsymbols("steer_torque") system.add_actuators(TorqueActuator( steer_torque, bicycle.rear_frame.steer_hub.axis, diff --git a/examples/whipple_upper_rider_simulation/model.py b/examples/whipple_upper_rider_simulation/model.py index b26ef54..cdc6bd7 100644 --- a/examples/whipple_upper_rider_simulation/model.py +++ b/examples/whipple_upper_rider_simulation/model.py @@ -76,7 +76,7 @@ system = br.to_system() g = symbols("g") -system.apply_gravity(-g * bicycle.ground.get_normal(bicycle.ground.origin)) +system.apply_uniform_gravity(-g * bicycle.ground.get_normal(bicycle.ground.origin)) disturbance = dynamicsymbols("disturbance") system.add_loads(Force( bicycle.rear_frame.saddle.point, disturbance * bicycle.rear_frame.wheel_hub.axis)) diff --git a/tests/test_simulator.py b/tests/test_simulator.py index 93a5817..699ef57 100644 --- a/tests/test_simulator.py +++ b/tests/test_simulator.py @@ -25,8 +25,9 @@ def create_rolling_disc(self) -> None: self.rolling_disc.define_loads() self.rolling_disc.define_constraints() self.system = self.rolling_disc.to_system() - self.system.apply_gravity(-symbols("g") * self.rolling_disc.ground.get_normal( - self.rolling_disc.ground.origin)) + self.system.apply_uniform_gravity( + -symbols("g") * self.rolling_disc.ground.get_normal( + self.rolling_disc.ground.origin)) self.system.add_loads( Torque(self.rolling_disc.disc.frame, dynamicsymbols("T") * self.rolling_disc.disc.rotation_axis)) diff --git a/utilities/simulator.py b/utilities/simulator.py index 24658d0..ef9a2cd 100644 --- a/utilities/simulator.py +++ b/utilities/simulator.py @@ -1,4 +1,4 @@ -"""Module for simulating sympy.physics.mechanics._system.System objects.""" +"""Module for simulating sympy.physics.mechanics.system.System objects.""" from __future__ import annotations from typing import Callable @@ -11,17 +11,17 @@ from sympy import Basic, Function, lambdify from sympy.physics.mechanics import ( KanesMethod, + System, dynamicsymbols, find_dynamicsymbols, msubs, ) -from sympy.physics.mechanics._system import System __all__ = ["Simulator"] class Simulator: - """Simulator for sympy.physics.mechanics._system.System object.""" + """Simulator for sympy.physics.mechanics.system.System object.""" def __init__(self, system: System) -> None: if not isinstance(system, System):