Я создаю симуляцию затухания орбиты и не знаю, как остановить/прервать симуляцию при столкновении объекта с поверхностью. Он продолжает моделировать поверхность планеты и не дает мне точного момента столкновения с поверхностью.
Вот код:
Я создаю симуляцию затухания орбиты и не знаю, как остановить/прервать симуляцию при столкновении объекта с поверхностью. Он продолжает моделировать поверхность планеты и не дает мне точного момента столкновения с поверхностью. Вот код: [code]import numpy as np import scipy.integrate as sci import matplotlib.pyplot as plt from mpl_toolkits import mplot3d
###Cube satelite mass = 1 #Kg S = 1/100 #Trasnversal area CD = 2
###Initial Conditions ''' I'll have a R3 cartesian system. Therefore i'll have to set the planet in terms of xyz and Vector position, speed and force in those unit vectors. So i'll define all vectors as arrays. ''' x0 = 0 y0 = Rplanet + 350000 z0 = 0 r0 = Rplanet + 350000 velx0 = 0 vely0 = 0 velz0 = np.sqrt((G*mplanet)/r0) period = 1e5
xdot = velx0 ydot = vely0 zdot = velz0
###AeroDynamics Model class Aerodynamics(): def __init__(self, name): self.name = name if name == 'Earth': ###Model with earth data self.beta = 0.1354/1000 #Desity constant self.rhos = 1.225 #kg/m^3 def getDensity(self, altitude): if self.name == 'Earth': rho = self.rhos*np.exp(-altitude*self.beta) return rho
aeroModel = Aerodynamics(name)
###Gravity model
def gravity(x, y, z): global Rplanet, mplanet, G
r = np.sqrt(x**2 + y**2 + z**2)
if r < Rplanet: accelx = 0 accely = 0 accelz = 0 else: accelx = (G*mplanet)*x/(r**3) accely = (G*mplanet)*y/(r**3) accelz = (G*mplanet)*z/(r**3) return np.asarray([accelx, accely, accelz]), r
###Differential equation of the system def Derivatives(state, t): global mass
x = state[0] y = state[1] z = state[2] velx = state[3] vely = state[4] velz = state[5]
xdot = velx ydot = vely zdot = velz
###Forces ###Gravity accel, r = gravity(x, y, z) GravityF = -accel*mass