示例#1
0
def new_random_array(size) :
    p_array = hichi.ParticleArray()  #type = ELECTRON
    for i in range(size) :
        pos = hichi.Vector3d(1.2*i, 3.4*i, 5.6*i)
        mo = hichi.Vector3d(9.8*i, 7.6*i, 54.3*i)
        new_p = hichi.Particle(pos, mo, 0.5, hichi.ELECTRON)
        p_array.add(new_p)
    return p_array
def gen_electron(gamma):
    """Electron creation.

    Args:
        gamma: energy

    Returns:
        electron
    """

    pos = pfc.Vector3d(0, 0, 0)

    momentum_x = gamma * pfc.LIGHT_VELOCITY * pfc.ELECTRON_MASS
    momentum = pfc.Vector3d(momentum_x, 0, 0)
    particle = pfc.Particle(pos, momentum, 1.0, pfc.ELECTRON)

    return particle
示例#3
0
import sys
sys.path.append("../bin/")
import pyHiChi as hichi

# ensemble
ensemble = hichi.Ensemble()
for i in range(11):
    pos = hichi.Vector3d(1.2 * i, 1.3 * i, 1.6 * i)
    mo = hichi.Vector3d(1.1 * i, 1.4 * i, 1.5 * i)
    new_p = hichi.Particle(pos, mo, 0.5, hichi.ELECTRON)
    ensemble.add(new_p)
for i in range(10):
    pos = hichi.Vector3d(13 * i, 14 * i, 17 * i)
    mo = hichi.Vector3d(12 * i, 15 * i, 16 * i)
    new_p = hichi.Particle(pos, mo, 0.5, hichi.POSITRON)
    ensemble.add(new_p)
for i in range(13):
    pos = hichi.Vector3d(140 * i, 150 * i, 180 * i)
    mo = hichi.Vector3d(130 * i, 160 * i, 170 * i)
    new_p = hichi.Particle(pos, mo, 0.5, hichi.PROTON)
    ensemble.add(new_p)

print('Count Particles: ', ensemble.size())
print('Count Electron: ',
      ensemble['Electron'].size())  #use index 'Electron' or hichi.ELECTRON
print('Count Positron: ', ensemble['Positron'].size())  #same Electron
print('Count Proton: ', ensemble['Proton'].size())  #same Electron

print('Positions Electron: ')
for elem in ensemble[hichi.ELECTRON]:
    print(elem.get_position())
    E = hichi.Vector3d(10**-5, 10**-5, 10**-5)  #sin(pos.x)
    return E


def value_B_analytical(pos, t):
    B = hichi.Vector3d(0, 0, 0)
    return B


t = 0
p_array = hichi.ParticleArray()
fields_array = []
for i in range(11):
    pos = hichi.Vector3d(1.2 * i, 3.4 * i, 5.6 * i)
    mo = hichi.Vector3d(i * 10, 0, 0)
    new_p = hichi.Particle(pos, mo, 0.5, hichi.ELECTRON)
    p_array.add(new_p)
    fields_array.append(
        hichi.FieldValue(value_E_analytical(pos, t),
                         value_B_analytical(pos, t)))

#Boris Pusher with RadiationReaction
dt = 0.001
pusher = hichi.BorisPusher()
rr = hichi.RadiationReaction()
for k in range(11):
    print(p_array[0].get_momentum())
    pusher(p_array, fields_array, dt)
    rr(p_array, fields_array, dt)
    t = dt * k
    for j in range(11):
示例#5
0
import sys
sys.path.append("../bin/")
import pyHiChi as hichi

v = hichi.Vector3d(1.2, 2.2, 3.4)
v2 = hichi.Vector3d(34, 5.6, 7.8)

#Particle
p = hichi.Particle()
print(p.get_position())
p.set_position(v)
print(p.get_position())
p.set_position(hichi.Vector3d(1.2, 2.1, 1.2))
print(p.get_position())
p.set_momentum(v2)
print(p.get_momentum())
p.set_momentum(hichi.Vector3d(3.4, 5.6, 7.8))
print(p.get_momentum())

mom = p.get_momentum()
print(mom.x)
print(p.get_momentum().y)

p.set_velocity(v)
print(p.get_velocity())
print(p.get_momentum())

print(p.get_type())
print(p.get_mass())
print(p.get_charge())
print(p.get_weight())