示例#1
0
    def __init__(self, gravity="SimpleNewton", atmos="ISA1976", wind = "NoWind"):
        self.earth_mass = 5.9722e24
        self.earth_radius = 6371000
        self.earth_grav_param = 3.986004418e14

        Planet.__init__(self, self.earth_mass,self.earth_radius, self.earth_grav_param, "Earth")

        if gravity == "SimpleNewton":
            gravity = SimpleNewton()
        if atmos == "ISA1976":
            atmo = ISA1976()
        if wind == "NoWind":
            wind = NoWind()

        self._environment = Environment(atmo, gravity, wind)
x0_1[2] = 0
x0_1[0] = 0

Ball = Body_FlatEarth(t0, x0_1)
Ball._set_mass(10)
Ball._set_name("Ball")
FixedPoint = Body_FlatEarth(t0, x0_2)
FixedPoint._set_mass(10000)
FixedPoint._set_name("Fixed Point")

atmo = ISA1976()
gravity = VerticalNewton()
#gravity = NoGravity()
wind = NoWind()
Env = Environment(atmo, gravity, wind)

Ball.set_environment(Env)
#FixedPoint.set_environment(Env) # If the fixed point is not being integrate, there is no need to assign an environment to it

rest_length = 5
stiffness = 600
damping = 100
spring = Ellastic_Rope_3DOF(FixedPoint, Ball, rest_length, stiffness, damping)
#spring = DampedSpring(FixedPoint, Ball, rest_length, stiffness, damping)

step_size = 0.001
t0 = 0
tf = 30
"""
Iteraton loop. For every time step, the spring (constraint) forces are calculated
示例#3
0
def main():

    t0 = 0
    #% Position, velocity, acceleration
    x0 = np.zeros(6)
    x0[0] = 6371000 + 10
    #x0[4] = 7600


    Ball1 = Body_RoundEarth(t0,x0, name="Ball1")
    Ball1._set_mass(10)

    x0_2 = copy.deepcopy(x0)
    x0_2[0] = x0_2[0] + 10
    Ball2 = Body_RoundEarth(t0,x0_2, name="Ball2")
    Ball2._set_mass(10)

    x0_3 = copy.deepcopy(x0_2)
    x0_3[0] = x0_3[0] + 10
    Ball3 = Body_RoundEarth(t0,x0_3, name="Ball3")
    Ball3._set_mass(10)

    x0_4 = copy.deepcopy(x0_3)
    x0_4[0] = x0_4[0] + 10
    Ball4 = Body_RoundEarth(t0,x0_4, name="Ball4")
    Ball4._set_mass(10)

    x0_5 = copy.deepcopy(x0_4)
    x0_5[0] = x0_5[0] + 10
    Ball5 = Body_RoundEarth(t0,x0_5, name="Ball5")
    Ball5._set_mass(10)

    x0_6 = copy.deepcopy(x0_5)
    x0_6[0] = x0_6[0] + 10
    Ball6 = Body_RoundEarth(t0,x0_6, name="Ball6")
    Ball6._set_mass(10)


    atmo = ISA1976()
    gravity = SimpleNewton()
    wind = NoWind()
    Env = Environment(atmo, gravity, wind)

    Ball1.set_environment(Env)
    Ball2.set_environment(Env)
    Ball3.set_environment(Env)
    Ball4.set_environment(Env)
    Ball5.set_environment(Env)
    Ball6.set_environment(Env)

    Balls = [Ball1, Ball2, Ball3, Ball4, Ball5, Ball6]


    step_size = 0.01
    t0 = 0
    tf = 100

    pool = mp.Pool(processes=6)

    results = [pool.apply(run_Body, args=(body, t0, tf, step_size)) for body in Balls]
    #for Ball in Balls:
        #for ii in np.arange(0,10, step_size):
            #Ball.step(step_size)



    results1 = pd.DataFrame(results[0].results)
    results2 = pd.DataFrame(results[1].results)
    results3 = pd.DataFrame(results[2].results)
示例#4
0
def main():

    t0 = 0
    #% Position, velocity, acceleration
    x0 = np.zeros(6)
    x0[0] = 6371000 + 100
    #x0[3] = 20
    #x0[4] = 7600


    Ball1 = Body_RoundEarth(t0,x0, name="Ball1")
    Ball1._set_mass(10)

    x0_2 = copy.deepcopy(x0)
    x0_2[0] = x0_2[0] + 10
    Ball2 = Body_RoundEarth(t0,x0_2, name="Ball2")
    Ball2._set_mass(10)

    #x0_3 = copy.deepcopy(x0_2)
    #x0_3[0] = x0_3[0] + 10
    #Ball3 = Body_RoundEarth(t0,x0_3, name="Ball3")
    #Ball3._set_mass(10)



    atmo = ISA1976()
    gravity = SimpleNewton()
    wind = NoWind()
    Env = Environment(atmo, gravity, wind)

    Ball1.set_environment(Env)
    Ball2.set_environment(Env)
    #Ball3.set_environment(Env)


    Balls = [Ball1, Ball2]

    rest_length = 9
    stiffness = 10
    damping = 0
    spring = DampedSpring_3DOF(Ball1, Ball2, rest_length, stiffness, damping)



    step_size = 00.1
    t0 = 0
    tf = 10


    for Ball in Balls:
        for ii in np.arange(t0,tf, step_size):
            Ball.step(step_size)



    results1 = pd.DataFrame(Ball1.results)
    #results2 = pd.DataFrame(Ball2.results)
    #results3 = pd.DataFrame(Ball3.results)


    #results.set_index('Time', inplace=True)
    #results.to_csv("out.csv")
    #print(Ball1.results)


    plt.plot(results1['Pos x'])
    #plt.plot(results2['Pos x'])
    #plt.plot(results3['Pos x'])
    plt.show()