Skip to content

Check big TVC angles #7

Description

@zuorenchen

TVC thrust3 uses sqrt(1 - sin(gimbal_x)^2 - sin(gimbal_y)^2). For moderate angles (e.g., 60° on both axes), the radicand becomes negative, producing NaNs and breaking the integration. Consider enforcing a physical combined gimbal limit (sin^2(x)+sin^2(y) <= 1), clamping the radicand to >= 0, and/or raising a clear error when angles exceed the feasible domain.

                gimbal_angle_x_rad = np.deg2rad(self.rocket.tvc.gimbal_angle_x)
                gimbal_angle_y_rad = np.deg2rad(self.rocket.tvc.gimbal_angle_y)
                sin_gimbal_x = np.sin(gimbal_angle_x_rad)
                sin_gimbal_y = np.sin(gimbal_angle_y_rad)
                sin_sum_sq = sin_gimbal_x**2 + sin_gimbal_y**2
                if sin_sum_sq > 1.0:
                    warnings.warn(
                        "TVC combined gimbal angles exceed the physical limit "
                        "(sin^2(x) + sin^2(y) > 1). Clamping axial thrust "
                        "component to maintain numerical stability.",
                        RuntimeWarning,
                    )
                    radicand = 0.0
                else:
                    radicand = 1.0 - sin_sum_sq
                thrust3 = net_thrust * np.sqrt(radicand)
                tvc_lever = self.rocket.nozzle_to_cdm
                # TVC Mx My moments: M = T * sin(x) * r
                M1 += sin_gimbal_x * net_thrust * tvc_lever
                M2 += sin_gimbal_y * net_thrust * tvc_lever

Originally posted by @Copilot in #5

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions