예제 #1
0
mu = 3.98e-4
m = 100000
r = lambda x, y, z: sqrt((x**2) + (y**2) + (z**2))
rt = 6.373
orb = [0, rt + 0.405, 0]
v = [-0.00766, 0.0001, 0]

N = ReferenceFrame(orb, name='iss')
iss = Object(m, ref_frame=N, Io=np.diag([50, 50, 50]), name='iss')
f = Force([0, 0, 0], ref_frame=N, name='gravity')

f.add_expression(lambda x, y, z, t: -mu * m * np.array([x, y, z]) /
                 (r(x, y, z)**3))
iss.apply_forces([f])
iss.apply_w([0.005, 0.007, 0.006])
iss.apply_v(v)

#DISEGNAMO LA TERRA
t, f = np.meshgrid(np.linspace(0, pi, 200), np.linspace(0, 2 * pi, 200))
xs = rt * np.sin(t) * np.cos(f)
ys = rt * np.sin(t) * np.sin(f)
zs = rt * np.cos(t)

fig = plt.figure()
ax = fig.add_subplot(111,
                     projection='3d',
                     aspect='equal',
                     xlim=(-10, 10),
                     ylim=(-10, 10),
                     zlim=(-10, 10))
예제 #2
0
from ReferenceFrame import ReferenceFrame
from Force import Force
from Object import Object
from DrawingSchema import Drawing_Schema
from math import pi,sqrt
import numpy as np

ref=ReferenceFrame([0,0,0],name='body_frame')
ref.orient_new([1,1,1],0)

obj=Object(1,ref_frame=ref,Io=np.diag([1,1,2]),name='obj1')
obj.apply_w([0,1,1])

#obj.draw(drawing_schema=Drawing_Schema(dt=1/60,lim=(-2,2),draw_str='mbw'),blit=True,n1=5,n2=5)
obj.integrate_and_draw(np.linspace(0,30,1000),drawing_schema=Drawing_Schema(
    dt=1/60,lim=(-2,2),draw_str='ambw'),blit=True,n1=10,n2=10)
예제 #3
0
ref = ReferenceFrame([70,70,70],name='body frame')
ref.orient_new_euler(0,0,0)

obj = Object(1,ref_frame=ref,name="Satellite")

npoints=100
theta = np.linspace(-10,10,npoints)
xs=5*np.cos(theta)
ys=5*np.sin(theta)
zs=0.3*theta

obj.compute_io(xs,ys,zs)
print(obj.Io)


obj.apply_w([1,0,7])
obj.apply_v([10,-10,-10])

mpoint=obj.mass/npoints

r = lambda x,y,z: sqrt((x**2)+(y**2)+(z**2))
GM=50000

farr=[]
for i in range(npoints):
    f=Force([xs[i],ys[i],zs[i]],name='gravity_'+str(i))
    expr = lambda x,y,z,t: -GM*mpoint*np.array([x,y,z])/(r(x,y,z)**3)
    f.add_expression(expr)
    farr.append(f)

obj.apply_forces(farr)