예제 #1
0
 def Advance(self):
     """
     Advance the simulation n steps, where n can be passed on the
     command line via --step option or by calling SetStepInterval.
     """
     warp.step(self._Step)
     return
예제 #2
0
 def Advance(self):
     """
     Advance the simulation n steps, where n can be passed on the
     command line via --step option or by calling SetStepInterval.
     """
     warp.step(self._Step)
     return
예제 #3
0
    def Initialize(self):
        """
        This will be called as part of start up. This method should be
        overriden to configure the simulation initial condition etc.

        This implementation takes n steps, where n may be passed on the
        command line via the --start option, or by calling SetStartIteration.
        """
        warp.step(self._Start)
        return
예제 #4
0
    def Initialize(self):
        """
        This will be called as part of start up. This method should be
        overriden to configure the simulation initial condition etc.

        This implementation takes n steps, where n may be passed on the
        command line via the --start option, or by calling SetStartIteration.
        """
        warp.step(self._Start)
        return
예제 #5
0
 def Advance(self):
     """
     Specialization for two phases of plotting, an inital presumably
     low frequency phase where we monitor sim nstartup, and a final
     presumably high frequency phase to capture results.
     """
     if warp.warp.top.it < self._InitStop:
         # initial
         warp.step(self._InitStep)
     else:
         # final
         return super(LPATwoColorSimulation,self).Advance()
예제 #6
0
 def Advance(self):
     """
     Specialization for two phases of plotting, an inital presumably
     low frequency phase where we monitor sim nstartup, and a final
     presumably high frequency phase to capture results.
     """
     if warp.warp.top.it < self._InitStop:
         # initial
         warp.step(self._InitStep)
     else:
         # final
         return super(LPATwoColorSimulation, self).Advance()
예제 #7
0
# --- The lattice period length, used to calculate phase advances.
wp.top.tunelen = 2. * hlp

# --- The start and end of the envelope calculation. The initial conditions
# --- are the values at env.zl. Note that zl and zu must cover
# --- the longitudinal extent where the beam particles will be loaded.
# --- dzenv is the step size used in the envelope solver.
wp.env.zl = -2.5 * hlp  # z-lower
wp.env.zu = -wp.env.zl  # z-upper
wp.env.dzenv = wp.top.tunelen / 100.

# --- Select the envelope solver, do any initialization, and solve the equations.
wp.package("env")
wp.generate()
wp.step()

# --- Make a plot of the resulting envelope solution.
wp.penv()
wp.fma()

# ------------------------------------------------------------------------
# --- Now, set up the parameters describing the 3D simulation.

# --- Specify the time step size. In this case, it is set so that
# --- it takes the specified number of time steps per lattice period.
steps_p_perd = 50
wp.top.dt = (wp.top.tunelen / steps_p_perd) / beam.vbeam

# --- Specify the number of grid cells in each dimension.
wp.w3d.nx = 32
예제 #8
0
    wp.fma()
    wp.pzcurr()
    wp.limits(wp.w3d.zmminglobal, wp.w3d.zmmaxglobal, 0., diode_current * 1.5)
    wp.refresh()


if steady_state_gun:
    # --- Steady-state operation
    # --- This does steady-state gun iterations, plotting the z versus r
    # --- after each iteration.
    wp.top.inj_param = 0.2
    for iter in range(10):
        gun(1, ipstep=1, lvariabletimestep=1)
        beamplots()

else:

    # --- Call beamplots after every 20 steps
    @cwp.allfromafterstep
    def makebeamplots():
        if top.it % 20 == 0:
            beamplots()

    wp.step(700)

# --- Make sure that last plot frames get sent to the cgm file
wp.window(0)
wp.hcp()
wp.window(1)
wp.hcp()
예제 #9
0
    #                                                           period=fieldperiod)
    # installafterstep(bfield_diagnostic_0.write)

# Crossing Diagnostics
##zcross_l = ZCrossingParticles(zz=z_positions[1], laccumulate=1)
##zcross_r = ZCrossingParticles(zz=z_positions[4], laccumulate=1)
#zcross_l = ZCrossingParticles(zz=5.*dz, laccumulate=1)
#zcross_r = ZCrossingParticles(zz=cooler_length-5.*dz, laccumulate=1)

###########################
# Generate and Run PIC Code
###########################

#electrons_tracked_t0 = wp.Species(type=wp.Electron)
#tracer_count = 50

wp.derivqty()  # Set derived beam properties if any are required
wp.package("w3d")  # Use w3d solver/geometry package
wp.generate()  # Allocate arrays, generate mesh, perform initial field solve

#wp.restart('magnetized_cooler3200000')

Nsteps = 60000
#particle_diagnostic_switch = False
#field_diagnostic_switch = False

while wp.top.it < Nsteps:
    wp.step(1000)
#    if wp.top.it % 100000 == 0 and wp.comm_world.rank == 0:
#        wp.dump()
예제 #10
0
wp.derivqty()  # Set derived beam properties if any are required
wp.package("w3d")  # Use w3d solver/geometry package
wp.generate()  # Allocate arrays, generate mesh, perform initial field solve

loss_hist = []

#wp.restart('magnetized_cooler3200000')

Nsteps = 5000000
#particle_diagnostic_switch = False
#field_diagnostic_switch = False

while wp.top.it < Nsteps:

    wp.step(1000)

#        try:
#            np.save("trajectories_{}.npy".format(wp.top.it), electron_tracker_0.getsavedata())
#            electron_tracker_0.reset(clearhistory=1)
#        except:
#            pass
#        v_coords = np.ones([tracer_count, 3]) * beam_beta * wp.clight
#        v_coords[:, [0, 1]] = 0.0
#        x_vals = np.linspace(-beam_radius, beam_radius, tracer_count)
#        y_vals = np.zeros([tracer_count,])
#        z_vals = np.zeros(tracer_count) + 1e-3 
#        eptclArray = np.asarray([x_vals, v_coords[:,0], y_vals, v_coords[:,1], z_vals, v_coords[:,2]]).T
#        electron_tracker_0 = TraceParticle(js=electrons_tracked_t0.jslist[0],
#                                           x=eptclArray[:,0],
#                                           y=eptclArray[:,2],