예제 #1
0
def print_debug():

    print("time: {0:.2E}  ".format(PhysicalObject.get_total_time()), end='')
    print("distance to mars: {0:.2E}\t".format(mars.distance_with(rocket)),
          end='')
    print("distance to earth: {0:.2E}   ".format(earth.distance_with(rocket)),
          end='')
    print("energy used: {0:.2E}\t".format(get_total_energy()), end='')

    # print("Net force on earth: {0:.2E} ".format(earth.get_net_force().mag))
    # print("Accln: {0:.2E} ".format(earth.accln().mag))

    print()
예제 #2
0
        render = frame > MAIN_SKIPS

        PhysicalObject.update_bodies(render)
        add_energy(rocket.get_net_propulsion(), rocket.vel, dt)

        frame += 1

        # print((rocket.pos - mars.pos).mag)
        # print(render)
        # print(FRAME_RATE)
        print_debug()
        # print(abs((DISTANCE_BETWEEN_SUN_AND_MARS-RADIUS_OF_MARS) - rocket.pos.mag), PhysicalObject.get_total_time())
        diff = abs(rocket.pos.mag - DISTANCE_BETWEEN_SUN_AND_MARS -
                   RADIUS_OF_MARS)
        if diff > lastdiff and PhysicalObject.get_total_time() > 8000000:
            print("Difference in distance started to increase")
            print(rocket.pos, rocket.vel)
            print(mars.pos, mars.vel)
            print(mars.pos.diff_angle(rocket.pos))
            print("distance from mars: {}, total energy: {}, total time: {}".
                  format(diff, get_total_energy(),
                         PhysicalObject.get_total_time()))
            print("DISTANCE FROM MARS orbit: {}".format(diff))

            with open("energy-used.tmp", "a") as f:
                f.write(str(get_total_energy()) + "\n")

            break
        else:
            lastdiff = diff