Exemplo n.º 1
0
def init_title():
    # Create a fake sim and make it do a force calculation
    # which sets Force_Title
    # Stupid hack but it works.  Until it doesn't.
    sim = ps.Simulation(total_force=Total_force)
    sim.add_ep_a((0.0, 0.0, 0.0))
    sim.init_world()
Exemplo n.º 2
0
def main():
    print("Mag test")
    sim = ps.Simulation()
    e, p = sim.add_ep_a((0.0, 0.0, 0.0))
    e2 = sim.add_e_a((10000.0, 0.0, 0.0), v=(0.0, 0.0, 0.0))
    print(e.cur_state)
    print(p.cur_state)
    vp = np.abs(p.cur_state.v[1])
    print("======= v is zero:")
    do(e, p, e2)

    print("======= Match Proton speed:")
    e2.cur_state.v[1] = -vp
    do(e, p, e2)

    print("======= Match -Proton speed:")
    e2.cur_state.v[1] = vp
    do(e, p, e2)

    print("======= Match Electron speed:")
    e2.cur_state.v[1] = e.cur_state.v[1]
    do(e, p, e2)

    print("======= Match -Electron speed:")
    e2.cur_state.v[1] = -e.cur_state.v[1]
    do(e, p, e2)
Exemplo n.º 3
0
def do_6h():
    """ Test of 6H (6P 6E) """
    sim = ps.Simulation(title="do_6h " + Force_Title,
                        pixels_per_angstrom=10000,
                        total_force=Total_force,
                        do_v_force=False,
                        dt_max=1e-20,
                        # dt_max=1e-30,
                        # pull_center_force=4e-7,
                        )

    e, p = sim.add_ep_a((0.0, 0.0, 0.000), radius=0.001)
    print(p.cur_state)
    print(e.cur_state)
    e, p = sim.add_ep_a((0.009, 0.001, 0.01), radius=0.001454)
    print(p.cur_state)
    print(e.cur_state)
    _e, _p = sim.add_ep_a((0.02, 0.0, 0.03), radius=0.0008)
    _e, _p = sim.add_ep_a((0.0, 0.02, 0.01), radius=0.002)
    _e, _p = sim.add_ep_a((0.01, 0.02, 0.02), radius=0.0025)
    _e, _p = sim.add_ep_a((0.02, 0.015, 0.03), radius=0.002)

    # sim.add_e_a((0.01, 0.01, 0.03), v=(100000.0, 0.00, 0.00))

    sim.run()
Exemplo n.º 4
0
def main():
    last_e = 0.0
    for r in range(1, 10):
        radius = r/10
        # radius /= ps.ANGSTROM
        sim = ps.Simulation()
        sim.add_ep_a((0.0, 0.0, 0.0), radius=radius)
        pe = sim.total_potential_energy()
        ke = sim.total_kinetic_energy()
        diff_e = ke+pe - last_e
        print(f"{radius=} PE:{pe:.3e} KE:{ke:.3e} Total:{pe+ke:.3e} Change from Last:{diff_e:.3e}")
        print(f"{-pe/ke=:.14f}")
        last_e = ke+pe

    sim = ps.Simulation(dt_max=1e-20)
    sim.add_ep_a((0.0, 0.0, 0.0), radius=1/ps.ANGSTROM)
Exemplo n.º 5
0
def main():
    """ Simple test of add_ep_a(). """
    sim = ps.Simulation(title="add_ep_a() Test", dt_max=2e-20)

    sim.add_ep_a((0.0, 0.0, 0.0))
    sim.add_ep_a((0.0, 1.0, 0.0), radius=0.15)
    sim.add_ep_a((1.0, 1.0, 0.0), radius=0.3)
    sim.add_ep_a((1.0, 0.0, 0.0), velocity=4000000)
    sim.add_ep_a((0.5, 0.5, 0.0), velocity=ps.CONST_C)

    sim.run()
Exemplo n.º 6
0
def main():
    """ Simple test of a Proton and a fake Neutron. """
    sim = ps.Simulation(title="PN Test nc 2.0", dt_max=2e-20)

    v = .010 * ps.CONST_C   # C is the speed of light.

    sim.add_p_a((0.1, 0.0, 0.0), v=(0.0, -v/18, 0.0))
    sim.add_n_a((0.2, 0.0, 0.0), v=(0.0, 0.000, 0.0), nc=2.0)
    sim.add_p_a((0.3, 0.0, 0.0), v=(0.0, v/18, 0.0))

    sim.add_e_a((0.8, 0.0, 0.0), v=(0.0, v, 0.0))
    sim.add_e_a((-0.4, 0.0, 0.0), v=(0.0, -v, 0.0))

    sim.run()
Exemplo n.º 7
0
def test_6h():
    """ Simple test of add_ep_a(). """
    sim = ps.Simulation(title="New V Force Test",
                        total_force=combined_es_v_force,
                        dt_max=1e-19)

    sim.add_p_a((0.3, 0.0, 0.0))
    # sim.add_ep_a((0.5, 0.0, 0.0))
    # sim.add_ep_a((0.5, 0.5, 0.5))
    # sim.add_ep_a((0.0, 0.5, 0.2), radius=0.05)
    # sim.add_ep_a((1.0, 0.0, 0.2), radius=0.05)
    # sim.add_ep_a((1.0, 0.5, 0.2), radius=0.05)

    sim.run()
Exemplo n.º 8
0
def do_2pe():
    """ Simple test of 2P and one E. """
    sim = ps.Simulation(title="do_2pe " + Force_Title,
                        pixels_per_angstrom=10000,
                        total_force=total_force,
                        dt_max=5e-23)

    # e: ps.Electron
    _e, _p = sim.add_ep_a((0.0, 0.0, 0.0), radius=0.001)
    # Swap y and z velocity to change orbit direction
    # e.cur_state.r[0], e.cur_state.r[2] = e.cur_state.r[2], e.cur_state.r[0]
    # e.charge *= 1.1

    sim.add_p_a((0.01, 0.0, 0.0001))

    sim.run()
Exemplo n.º 9
0
def test_2pe():
    """ Simple test of 2P and one E. """
    sim = ps.Simulation(title="2PE Test with new v_force",
                        pixels_per_angstrom=10000,
                        total_force=combined_es_v_force,
                        dt_max=5e-23)

    e: ps.Electron
    e, p = sim.add_ep_a((0.0, 0.0, 0.0), radius=0.001)
    # Swap y and z velocity to change orbit direction
    # e.cur_state.r[0], e.cur_state.r[2] = e.cur_state.r[2], e.cur_state.r[0]
    e.charge *= 1.1

    sim.add_p_a((0.01, 0.0, 0.0001))

    sim.run()
Exemplo n.º 10
0
def do_0h():
    """ Simple test of P and E falling together. """
    sim = ps.Simulation(title="do_0h " + Force_Title,
                        total_force=Total_force,
                        dt_max=1e-19,
                        dt_min=1e-24,
                        # pixels_per_angstrom=50,
                        pixels_per_angstrom=200,
                        )

    e, p = sim.add_ep_a((0.0, 0.0, 0.0), radius=1.0)
    e.cur_state.v[1] = 0.0
    e.cur_state.v[0] = -ps.CONST_C / 1000

    p.cur_state.v[1] = 0.0

    sim.run()
Exemplo n.º 11
0
def main():
    """ Simple test of 4 Hydrogen-like Atoms. """
    sim = ps.Simulation(title="4H Test", dt_max=2e-20)

    v = .012 * ps.CONST_C  # C is the speed of light.

    sim.add_p_a((0.2, 0.0, 0.0))
    sim.add_e_a((0.2, -0.1, 0.0), v=(v, 0.0, 0.0))

    sim.add_p_a((0.5, 0.0, 0.0))
    sim.add_e_a((0.5, 0.1, 0.1), v=(-v * .8, 0.0, 0.0))

    sim.add_p_a((1.0, 0.1, 0.0))
    sim.add_e_a((1.0, 0.2, 0.0), v=(v * 1.1, 0.0, 0.0))

    sim.add_p_a((0.5, 0.5, 1.0))
    sim.add_e_a((0.6, 0.6, 1.3), v=(0.0, v / 2, v / 2))

    sim.run()
Exemplo n.º 12
0
def do_2h():
    """ Simple test of p force with a single EP pair. """
    sim = ps.Simulation(title="do_2h " + Force_Title,
                        total_force=Total_force,
                        dt_max=1e-19,
                        # pixels_per_angstrom=50,
                        # pull_center_force=1e-10,
                        )

    # sim.add_p_a((0.3, 0.0, 0.0))
    # sim.add_ep_a((0.5, 0.0, 0.0))
    # sim.add_ep_a((0.5, 0.5, 0.5))
    e, p = sim.add_ep_a((0.0, 0.0, 0.0), radius=0.1)
    e.cur_state.v[1] *= 1.2

    # sim.add_p_a((0.2, 0.0, 0.0))
    # e, p = sim.add_ep_a((0.6, 0.0, 0.1), radius=0.08)

    # sim.add_ep_a((1.0, 0.0, 0.2), radius=0.05)
    _e, _p = sim.add_ep_a((1.0, 0.5, 1.0), radius=0.05)

    sim.run()
Exemplo n.º 13
0
def do_1h():
    """ Simple test of p force with a single EP pair. """
    sim = ps.Simulation(title="do_1h v_force" + Force_Title,
                        total_force=Total_force,
                        dt_max=1e-22,
                        # pixels_per_angstrom=50,
                        pixels_per_angstrom=20000,
                        )

    # Black hole in the middle! :)
    # n = sim.add_n((0, 0, 0), n=2)
    # n.lock_in_place = True

    # One EP in elliptical orbit.
    e, p = sim.add_ep_a((0.0, 0.0, 0.0), radius=0.001)
    e.cur_state.v[1] *= 1.3

    # f = 200
    #
    # # sim.add_p_a((0.3, 0.0, 0.0))
    # # sim.add_ep_a((0.5, 0.0, 0.0))
    # # sim.add_ep_a((0.5, 0.5, 0.5))
    # e, p = sim.add_ep_a((0.0, 0.0, 0.0), radius=0.1)
    # v = e.cur_state.v[1]  # v y of electron
    # e.cur_state.v[1] += v / f
    # p.cur_state.v[1] += v / f

    # e.cur_state.v[1] *= 1.3
    # sim.add_p_a((0.2, 0.0, 0.0))
    # e, p = sim.add_ep_a((0.6, 0.0, 0.1), radius=0.08)

    # # sim.add_ep_a((1.0, 0.0, 0.2), radius=0.05)
    # e, p = sim.add_ep_a((1.0, 0.5, 0.2), radius=0.2)
    # v = e.cur_state.v[1]  # v y of electron
    # e.cur_state.v[1] -= v / f
    # p.cur_state.v[1] -= v / f

    sim.run()
Exemplo n.º 14
0
def main():
    """ Speed of Light experiment, """

    c = ps.CONST_C  # Speed of Light in m/s

    sim = ps.Simulation(title="SOL Test")

    num = 20
    spacing = (2 / num)
    for cnt in range(num):
        sim.add_e_a((cnt * spacing, 0.0, 0.0))

    # world[0].p.lock_in_place = True
    sim.world[4].cur_state.v[0] = .05 * c

    sim.init_world()
    # The particle states, including the forces have been re-defined now.

    for p in sim.world:
        # Set static starting force to keep particles in place.
        # Trying to fake an infinitely long line of particles.
        p.static_f[:] = -p.cur_state.f

    sim.run()