diff --git a/CHANGELOG.md b/CHANGELOG.md index ee3c84968..acb9dc5da 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,6 +36,7 @@ Attention: The newest changes should be on top --> - ENH: Implement Multivariate Rejection Sampling (MRS) [#738] (https://github.com/RocketPy-Team/RocketPy/pull/738) - ENH: Create a rocketpy file to store flight simulations [#800](https://github.com/RocketPy-Team/RocketPy/pull/800) - ENH: Support for the RSE file format has been added to the library [#798](https://github.com/RocketPy-Team/RocketPy/pull/798) +- ENH: Add the Coriolis Force to the Flight class [#799](https://github.com/RocketPy-Team/RocketPy/pull/799) - ENH: Introduce Net Thrust with pressure corrections [#789](https://github.com/RocketPy-Team/RocketPy/pull/789) ### Changed diff --git a/rocketpy/environment/environment.py b/rocketpy/environment/environment.py index a0a8c4238..e12e3dd64 100644 --- a/rocketpy/environment/environment.py +++ b/rocketpy/environment/environment.py @@ -248,6 +248,8 @@ class Environment: Number of ensemble members. Only defined when using Ensembles. Environment.ensemble_member : int Current selected ensemble member. Only defined when using Ensembles. + Environment.earth_rotation_vector : list[float] + Earth's angular velocity vector in the Flight Coordinate System. Notes ----- @@ -353,6 +355,7 @@ def __init__( self.set_location(latitude, longitude) self.__initialize_earth_geometry(datum) self.__initialize_utm_coordinates() + self.__set_earth_rotation_vector() # Set the gravity model self.gravity = self.set_gravity_model(gravity) @@ -584,6 +587,23 @@ def __reset_wind_direction_function(self): self.wind_direction.set_outputs("Wind Direction (Deg True)") self.wind_direction.set_title("Wind Direction Profile") + def __set_earth_rotation_vector(self): + """Calculates and stores the Earth's angular velocity vector in the Flight + Coordinate System, which is essential for evaluating inertial forces. + """ + # Sidereal day + T = 86164.1 # seconds + + # Earth's angular velocity magnitude + w_earth = 2 * np.pi / T + + # Vector in the Flight Coordinate System + lat = np.radians(self.latitude) + w_local = [0, w_earth * np.cos(lat), w_earth * np.sin(lat)] + + # Store the attribute + self.earth_rotation_vector = w_local + # Validators (used to verify an attribute is being set correctly.) def __validate_dictionary(self, file, dictionary): diff --git a/rocketpy/simulation/flight.py b/rocketpy/simulation/flight.py index 94e97fee4..da183f373 100644 --- a/rocketpy/simulation/flight.py +++ b/rocketpy/simulation/flight.py @@ -1710,6 +1710,27 @@ def u_dot(self, t, u, post_processing=False): # pylint: disable=too-many-locals ax, ay, az = K @ Vector(L) az -= self.env.gravity.get_value_opt(z) # Include gravity + # Coriolis acceleration + _, w_earth_y, w_earth_z = self.env.earth_rotation_vector + ax -= 2 * ( + -a23 * vy * w_earth_y + + a22 * vz * w_earth_y + - a33 * vy * w_earth_z + + a32 * vz * w_earth_z + ) + ay -= 2 * ( + a23 * vx * w_earth_y + - a21 * vz * w_earth_y + + a33 * vx * w_earth_z + - a31 * vz * w_earth_z + ) + az -= 2 * ( + -a22 * vx * w_earth_y + + a21 * vy * w_earth_y + - a32 * vx * w_earth_z + + a31 * vy * w_earth_z + ) + # Create u_dot u_dot = [ vx, @@ -1776,7 +1797,7 @@ def u_dot_generalized(self, t, u, post_processing=False): # pylint: disable=too _, _, z, vx, vy, vz, e0, e1, e2, e3, omega1, omega2, omega3 = u # Create necessary vectors - # r = Vector([x, y, z]) # CDM position vector + # r = Vector([x, y, z]) # CDM position vector v = Vector([vx, vy, vz]) # CDM velocity vector e = [e0, e1, e2, e3] # Euler parameters/quaternions w = Vector([omega1, omega2, omega3]) # Angular velocity vector @@ -1935,8 +1956,9 @@ def u_dot_generalized(self, t, u, post_processing=False): # pylint: disable=too # Angular velocity derivative w_dot = I_CM.inverse @ (T21 + (T20 ^ r_CM)) - # Velocity vector derivative - v_dot = K @ (T20 / total_mass - (r_CM ^ w_dot)) + # Velocity vector derivative + Coriolis acceleration + w_earth = Kt @ Vector(self.env.earth_rotation_vector) + v_dot = K @ (T20 / total_mass - (r_CM ^ w_dot)) - 2 * (w_earth ^ v) # Euler parameters derivative e_dot = [