From 51787263c585c29dd44feebf299ba59f816376e5 Mon Sep 17 00:00:00 2001 From: Axel Huebl Date: Fri, 20 Oct 2023 10:11:29 -0700 Subject: [PATCH 1/5] src: ``beam.kin_energy``, ``set_kin_energy_MeV`` --- src/initialization/InitDistribution.cpp | 10 +++++----- src/initialization/Validate.cpp | 2 +- src/particles/ReferenceParticle.H | 16 ++++++++-------- src/python/ReferenceParticle.cpp | 6 +++--- src/python/impactx/madx_to_impactx.py | 6 +++--- 5 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/initialization/InitDistribution.cpp b/src/initialization/InitDistribution.cpp index 35876b8e3..b7be54029 100644 --- a/src/initialization/InitDistribution.cpp +++ b/src/initialization/InitDistribution.cpp @@ -39,7 +39,7 @@ namespace impactx "add_particles: Reference particle charge not yet set!"); AMREX_ALWAYS_ASSERT_WITH_MESSAGE(ref.mass_MeV() != 0.0, "add_particles: Reference particle mass not yet set!"); - AMREX_ALWAYS_ASSERT_WITH_MESSAGE(ref.energy_MeV() != 0.0, + AMREX_ALWAYS_ASSERT_WITH_MESSAGE(ref.kin_energy_MeV() != 0.0, "add_particles: Reference particle energy not yet set!"); AMREX_ALWAYS_ASSERT_WITH_MESSAGE(bunch_charge >= 0.0, @@ -112,8 +112,8 @@ namespace impactx // Parse the beam distribution parameters amrex::ParmParse const pp_dist("beam"); - amrex::ParticleReal energy = 0.0; // Beam kinetic energy (MeV) - pp_dist.get("energy", energy); + amrex::ParticleReal kin_energy = 0.0; // Beam kinetic energy (MeV) + pp_dist.get("kin_energy", kin_energy); amrex::ParticleReal bunch_charge = 0.0; // Bunch charge (C) pp_dist.get("charge", bunch_charge); @@ -145,7 +145,7 @@ namespace impactx // set charge and mass and energy of ref particle m_particle_container->GetRefParticle() - .set_charge_qe(qe).set_mass_MeV(massE).set_energy_MeV(energy); + .set_charge_qe(qe).set_mass_MeV(massE).set_kin_energy_MeV(kin_energy); int npart = 1; // Number of simulation particles pp_dist.get("npart", npart); @@ -300,7 +300,7 @@ namespace impactx } // print information on the initialized beam - amrex::Print() << "Beam kinetic energy (MeV): " << energy << std::endl; + amrex::Print() << "Beam kinetic energy (MeV): " << kin_energy << std::endl; amrex::Print() << "Bunch charge (C): " << bunch_charge << std::endl; amrex::Print() << "Particle type: " << particle_type << std::endl; amrex::Print() << "Number of particles: " << npart << std::endl; diff --git a/src/initialization/Validate.cpp b/src/initialization/Validate.cpp index de3c4434f..890a21ab7 100644 --- a/src/initialization/Validate.cpp +++ b/src/initialization/Validate.cpp @@ -24,7 +24,7 @@ namespace impactx // reference particle initialized? auto const & ref = m_particle_container->GetRefParticle(); - if (ref.energy_MeV() == 0.0) + if (ref.kin_energy_MeV() == 0.0) throw std::runtime_error("The reference particle energy is zero. Not yet initialized?"); // particles in the beam bunch diff --git a/src/particles/ReferenceParticle.H b/src/particles/ReferenceParticle.H index 8c3cee5dc..92d83ad5b 100644 --- a/src/particles/ReferenceParticle.H +++ b/src/particles/ReferenceParticle.H @@ -117,7 +117,7 @@ namespace impactx // re-scale pt and pz if (pt != 0.0_prt) { - pt = -energy_MeV() / massE - 1.0_prt; + pt = -kin_energy_MeV() / massE - 1.0_prt; pz = sqrt(pow(pt, 2) - 1.0_prt); } @@ -130,31 +130,31 @@ namespace impactx */ AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::ParticleReal - energy_MeV () const + kin_energy_MeV () const { using namespace amrex::literals; amrex::ParticleReal const ref_gamma = -pt; - amrex::ParticleReal const ref_energy = mass_MeV() * (ref_gamma - 1.0_prt); - return ref_energy; + amrex::ParticleReal const ref_kin_energy = mass_MeV() * (ref_gamma - 1.0_prt); + return ref_kin_energy; } /** Set reference particle kinetic energy * - * @param energy initial kinetic energy (MeV) + * @param kin_energy initial kinetic energy (MeV) */ AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE RefPart & - set_energy_MeV (amrex::ParticleReal const energy) + set_kin_energy_MeV (amrex::ParticleReal const kin_energy) { using namespace amrex::literals; AMREX_ASSERT_WITH_MESSAGE(mass != 0.0_prt, - "set_energy_MeV: Set mass first!"); + "set_kin_energy_MeV: Set mass first!"); px = 0.0; py = 0.0; - pt = -energy / mass_MeV() - 1.0_prt; + pt = -kin_energy / mass_MeV() - 1.0_prt; pz = sqrt(pow(pt, 2) - 1.0_prt); return *this; diff --git a/src/python/ReferenceParticle.cpp b/src/python/ReferenceParticle.cpp index 638e56f16..5fea7ceba 100644 --- a/src/python/ReferenceParticle.cpp +++ b/src/python/ReferenceParticle.cpp @@ -36,7 +36,7 @@ void init_refparticle(py::module& m) .def_property_readonly("beta", &RefPart::beta, "Get reference particle relativistic beta") .def_property_readonly("beta_gamma", &RefPart::beta_gamma, "Get reference particle beta*gamma") .def_property_readonly("mass_MeV", &RefPart::mass_MeV, "Get reference particle rest mass (MeV/c^2)") - .def_property_readonly("energy_MeV", &RefPart::energy_MeV, "Get reference particle energy (MeV)") + .def_property_readonly("kin_energy_MeV", &RefPart::kin_energy_MeV, "Get reference particle energy (MeV)") .def_property_readonly("rigidity_Tm", &RefPart::rigidity_Tm, "Get reference particle magnetic rigidity Brho (T*m)") .def_property_readonly("qm_qeeV", &RefPart::qm_qeeV, "Get reference particle charge to mass ratio (charge/eV)") @@ -46,8 +46,8 @@ void init_refparticle(py::module& m) .def("set_mass_MeV", &RefPart::set_mass_MeV, py::return_value_policy::reference_internal, "Set reference particle rest mass (MeV/c^2)", py::arg("mass_MeV")) - .def("set_energy_MeV", &RefPart::set_energy_MeV, + .def("set_kin_energy_MeV", &RefPart::set_kin_energy_MeV, py::return_value_policy::reference_internal, - "Set reference particle kinetic energy (MeV)", py::arg("energy_MeV")) + "Set reference particle kinetic energy (MeV)", py::arg("kin_energy_MeV")) ; } diff --git a/src/python/impactx/madx_to_impactx.py b/src/python/impactx/madx_to_impactx.py index b2dedf834..db8a698ca 100644 --- a/src/python/impactx/madx_to_impactx.py +++ b/src/python/impactx/madx_to_impactx.py @@ -122,7 +122,7 @@ def beam(particle, charge=None, mass=None, energy=None): :param str particle: reference particle name :param float charge: particle charge (proton charge units) :param float mass: particle mass (electron masses) - :param float energy: particle energy (GeV) + :param float energy: total particle energy (GeV) - MAD-X default: 1 GeV :return dict: dictionary containing particle and beam attributes in ImpactX units """ @@ -131,7 +131,7 @@ def beam(particle, charge=None, mass=None, energy=None): kg2MeV = sc.c**2 / sc.electron_volt * 1.0e-6 muon_mass = sc.physical_constants["electron-muon mass ratio"][0] / sc.m_e if energy is None: - energy_MeV = 1.0e3 # MAD-X default is 1 GeV particle energy + energy_MeV = 1.0e3 # MAD-X default is 1 GeV total particle energy else: energy_MeV = energy * GeV2MeV @@ -192,6 +192,6 @@ def read_beam(ref: RefPart, madx_file): ref.set_charge_qe(ref_particle_dict["charge"]) ref.set_mass_MeV(ref_particle_dict["mass"]) - ref.set_energy_MeV(ref_particle_dict["energy"]) + ref.set_kin_energy_MeV(ref_particle_dict["energy"] - ref_particle_dict["mass"]) return ref From d4e8126a0dbdc7706bf0f494ba6b67230e2dc89a Mon Sep 17 00:00:00 2001 From: Axel Huebl Date: Fri, 20 Oct 2023 10:12:09 -0700 Subject: [PATCH 2/5] Examples/Tests: New Kin Energy APIs --- examples/cfbend/input_cfbend.in | 2 +- examples/cfbend/run_cfbend.py | 4 ++-- examples/cfchannel/input_cfchannel.in | 2 +- examples/cfchannel/input_cfchannel_10nC.in | 2 +- examples/cfchannel/run_cfchannel.py | 4 ++-- examples/cfchannel/run_cfchannel_10nC.py | 4 ++-- examples/chicane/input_chicane.in | 2 +- examples/chicane/run_chicane.py | 4 ++-- examples/compression/input_compression.in | 2 +- examples/compression/run_compression.py | 4 ++-- examples/cyclotron/input_cyclotron.in | 2 +- examples/cyclotron/run_cyclotron.py | 4 ++-- examples/distgen/input_gaussian.in | 2 +- examples/distgen/input_kurth4d.in | 2 +- examples/distgen/input_kvdist.in | 2 +- examples/distgen/input_semigaussian.in | 2 +- examples/expanding_beam/input_expanding.in | 2 +- examples/expanding_beam/run_expanding.py | 4 ++-- examples/fodo/input_fodo.in | 2 +- examples/fodo/run_fodo.py | 4 ++-- examples/fodo/run_fodo_madx.py | 2 +- examples/fodo/run_fodo_programmable.py | 4 ++-- examples/fodo_chromatic/input_fodo_chr.in | 2 +- examples/fodo_chromatic/run_fodo_chr.py | 4 ++-- examples/fodo_rf/input_fodo_rf.in | 2 +- examples/fodo_rf/run_fodo_rf.py | 4 ++-- examples/iota_lattice/input_iotalattice.in | 2 +- examples/iota_lattice/run_iotalattice.py | 4 ++-- examples/iota_lens/input_iotalens.in | 2 +- examples/iota_lens/run_iotalens.py | 4 ++-- examples/kicker/input_kicker.in | 2 +- examples/kicker/run_kicker.py | 4 ++-- examples/kurth/input_kurth_10nC_periodic.in | 2 +- examples/kurth/input_kurth_periodic.in | 2 +- examples/kurth/run_kurth_10nC_periodic.py | 4 ++-- examples/kurth/run_kurth_periodic.py | 4 ++-- examples/multipole/input_multipole.in | 2 +- examples/multipole/run_multipole.py | 4 ++-- examples/positron_channel/input_positron.in | 2 +- examples/positron_channel/run_positron.py | 4 ++-- examples/quadrupole_softedge/input_quadrupole_softedge.in | 2 +- examples/quadrupole_softedge/run_quadrupole_softedge.py | 4 ++-- examples/rfcavity/input_rfcavity.in | 2 +- examples/rfcavity/run_rfcavity.py | 4 ++-- examples/rotation/input_rotation.in | 2 +- examples/rotation/run_rotation.py | 4 ++-- examples/solenoid/input_solenoid.in | 2 +- examples/solenoid/run_solenoid.py | 4 ++-- examples/solenoid_softedge/input_solenoid_softedge.in | 2 +- examples/solenoid_softedge/run_solenoid_softedge.py | 4 ++-- tests/python/test_impactx.py | 8 ++++---- tests/python/test_transformation.py | 6 +++--- 52 files changed, 80 insertions(+), 80 deletions(-) diff --git a/examples/cfbend/input_cfbend.in b/examples/cfbend/input_cfbend.in index 0d6054a84..07fe04151 100644 --- a/examples/cfbend/input_cfbend.in +++ b/examples/cfbend/input_cfbend.in @@ -3,7 +3,7 @@ ############################################################################### beam.npart = 10000 beam.units = static -beam.energy = 2.0e3 #2 GeV +beam.kin_energy = 2.0e3 #2 GeV beam.charge = 1.0e-9 beam.particle = electron beam.distribution = waterbag diff --git a/examples/cfbend/run_cfbend.py b/examples/cfbend/run_cfbend.py index 87edab38f..071f0b727 100644 --- a/examples/cfbend/run_cfbend.py +++ b/examples/cfbend/run_cfbend.py @@ -22,13 +22,13 @@ # load a 5 GeV electron beam with an initial # normalized transverse rms emittance of 1 um -energy_MeV = 2.0e3 # reference energy +kin_energy_MeV = 2.0e3 # reference energy bunch_charge_C = 1.0e-9 # used with space charge npart = 10000 # number of macro particles # reference particle ref = sim.particle_container().ref_particle() -ref.set_charge_qe(-1.0).set_mass_MeV(0.510998950).set_energy_MeV(energy_MeV) +ref.set_charge_qe(-1.0).set_mass_MeV(0.510998950).set_kin_energy_MeV(kin_energy_MeV) # particle bunch distr = distribution.Waterbag( diff --git a/examples/cfchannel/input_cfchannel.in b/examples/cfchannel/input_cfchannel.in index cb455298a..b155e4483 100644 --- a/examples/cfchannel/input_cfchannel.in +++ b/examples/cfchannel/input_cfchannel.in @@ -3,7 +3,7 @@ ############################################################################### beam.npart = 10000 beam.units = static -beam.energy = 2.0e3 +beam.kin_energy = 2.0e3 beam.charge = 1.0e-9 beam.particle = proton beam.distribution = waterbag diff --git a/examples/cfchannel/input_cfchannel_10nC.in b/examples/cfchannel/input_cfchannel_10nC.in index c4d34c260..f01669f3f 100644 --- a/examples/cfchannel/input_cfchannel_10nC.in +++ b/examples/cfchannel/input_cfchannel_10nC.in @@ -4,7 +4,7 @@ beam.npart = 10000 #beam.npart = 100000 # optional for increased precision beam.units = static -beam.energy = 2.0e3 +beam.kin_energy = 2.0e3 beam.charge = 1.0e-8 beam.particle = proton beam.distribution = waterbag diff --git a/examples/cfchannel/run_cfchannel.py b/examples/cfchannel/run_cfchannel.py index 375b2ccdd..bf31e71fa 100755 --- a/examples/cfchannel/run_cfchannel.py +++ b/examples/cfchannel/run_cfchannel.py @@ -22,13 +22,13 @@ # load a 2 GeV proton beam with an initial # normalized transverse rms emittance of 1 um -energy_MeV = 2.0e3 # reference energy +kin_energy_MeV = 2.0e3 # reference energy bunch_charge_C = 1.0e-9 # used with space charge npart = 10000 # number of macro particles # reference particle ref = sim.particle_container().ref_particle() -ref.set_charge_qe(1.0).set_mass_MeV(938.27208816).set_energy_MeV(energy_MeV) +ref.set_charge_qe(1.0).set_mass_MeV(938.27208816).set_kin_energy_MeV(kin_energy_MeV) # particle bunch distr = distribution.Waterbag( diff --git a/examples/cfchannel/run_cfchannel_10nC.py b/examples/cfchannel/run_cfchannel_10nC.py index 61c4e6d23..7965a26ca 100755 --- a/examples/cfchannel/run_cfchannel_10nC.py +++ b/examples/cfchannel/run_cfchannel_10nC.py @@ -24,13 +24,13 @@ # load a 2 GeV proton beam with an initial # normalized transverse rms emittance of 1 um -energy_MeV = 2.0e3 # reference energy +kin_energy_MeV = 2.0e3 # reference energy bunch_charge_C = 1.0e-8 # used with space charge npart = 10000 # number of macro particles; use 1e5 for increased precision # reference particle ref = sim.particle_container().ref_particle() -ref.set_charge_qe(1.0).set_mass_MeV(938.27208816).set_energy_MeV(energy_MeV) +ref.set_charge_qe(1.0).set_mass_MeV(938.27208816).set_kin_energy_MeV(kin_energy_MeV) # particle bunch distr = distribution.Waterbag( diff --git a/examples/chicane/input_chicane.in b/examples/chicane/input_chicane.in index 6f88fcd15..518eee2eb 100644 --- a/examples/chicane/input_chicane.in +++ b/examples/chicane/input_chicane.in @@ -3,7 +3,7 @@ ############################################################################### beam.npart = 10000 beam.units = static -beam.energy = 5.0e3 +beam.kin_energy = 5.0e3 beam.charge = 1.0e-9 beam.particle = electron beam.distribution = waterbag diff --git a/examples/chicane/run_chicane.py b/examples/chicane/run_chicane.py index c1cc01b3e..c839436db 100644 --- a/examples/chicane/run_chicane.py +++ b/examples/chicane/run_chicane.py @@ -22,13 +22,13 @@ # load a 5 GeV electron beam with an initial # normalized transverse rms emittance of 1 um -energy_MeV = 5.0e3 # reference energy +kin_energy_MeV = 5.0e3 # reference energy bunch_charge_C = 1.0e-9 # used with space charge npart = 10000 # number of macro particles # reference particle ref = sim.particle_container().ref_particle() -ref.set_charge_qe(-1.0).set_mass_MeV(0.510998950).set_energy_MeV(energy_MeV) +ref.set_charge_qe(-1.0).set_mass_MeV(0.510998950).set_kin_energy_MeV(kin_energy_MeV) # particle bunch distr = distribution.Waterbag( diff --git a/examples/compression/input_compression.in b/examples/compression/input_compression.in index cc2315059..e083268cc 100644 --- a/examples/compression/input_compression.in +++ b/examples/compression/input_compression.in @@ -3,7 +3,7 @@ ############################################################################### beam.npart = 10000 beam.units = static -beam.energy = 20.0 +beam.kin_energy = 20.0 beam.charge = 1.0e-9 beam.particle = electron beam.distribution = waterbag diff --git a/examples/compression/run_compression.py b/examples/compression/run_compression.py index 3fd36ecb9..d54e4bcf9 100644 --- a/examples/compression/run_compression.py +++ b/examples/compression/run_compression.py @@ -23,13 +23,13 @@ # load a 250 MeV proton beam with an initial # unnormalized rms emittance of 1 mm-mrad in all # three phase planes -energy_MeV = 20.0 # reference energy +kin_energy_MeV = 20.0 # reference energy bunch_charge_C = 1.0e-9 # used with space charge npart = 10000 # number of macro particles # reference particle ref = sim.particle_container().ref_particle() -ref.set_charge_qe(-1.0).set_mass_MeV(0.510998950).set_energy_MeV(energy_MeV) +ref.set_charge_qe(-1.0).set_mass_MeV(0.510998950).set_kin_energy_MeV(kin_energy_MeV) # particle bunch distr = distribution.Waterbag( diff --git a/examples/cyclotron/input_cyclotron.in b/examples/cyclotron/input_cyclotron.in index 42f7e5f4d..7f76be873 100644 --- a/examples/cyclotron/input_cyclotron.in +++ b/examples/cyclotron/input_cyclotron.in @@ -3,7 +3,7 @@ ############################################################################### beam.npart = 10000 beam.units = static -beam.energy = 4.0e-3 +beam.kin_energy = 4.0e-3 beam.charge = 1.0e-9 beam.particle = proton beam.distribution = waterbag diff --git a/examples/cyclotron/run_cyclotron.py b/examples/cyclotron/run_cyclotron.py index 755bd3aec..90bdb8973 100755 --- a/examples/cyclotron/run_cyclotron.py +++ b/examples/cyclotron/run_cyclotron.py @@ -21,13 +21,13 @@ sim.init_grids() # load initial beam -energy_MeV = 4.0e-3 # reference energy +kin_energy_MeV = 4.0e-3 # reference energy bunch_charge_C = 1.0e-9 # used with space charge npart = 10000 # number of macro particles # reference particle ref = sim.particle_container().ref_particle() -ref.set_charge_qe(1.0).set_mass_MeV(938.27208816).set_energy_MeV(energy_MeV) +ref.set_charge_qe(1.0).set_mass_MeV(938.27208816).set_kin_energy_MeV(kin_energy_MeV) # particle bunch distr = distribution.Waterbag( diff --git a/examples/distgen/input_gaussian.in b/examples/distgen/input_gaussian.in index f2d3f1067..93484dc13 100644 --- a/examples/distgen/input_gaussian.in +++ b/examples/distgen/input_gaussian.in @@ -3,7 +3,7 @@ ############################################################################### beam.npart = 10000 beam.units = static -beam.energy = 2.0e3 +beam.kin_energy = 2.0e3 beam.charge = 1.0e-9 beam.particle = electron beam.distribution = gaussian diff --git a/examples/distgen/input_kurth4d.in b/examples/distgen/input_kurth4d.in index 91d88805c..039185a09 100644 --- a/examples/distgen/input_kurth4d.in +++ b/examples/distgen/input_kurth4d.in @@ -3,7 +3,7 @@ ############################################################################### beam.npart = 10000 beam.units = static -beam.energy = 2.0e3 +beam.kin_energy = 2.0e3 beam.charge = 1.0e-9 beam.particle = proton beam.distribution = kurth4d diff --git a/examples/distgen/input_kvdist.in b/examples/distgen/input_kvdist.in index 0b5fe96ac..0713571a0 100644 --- a/examples/distgen/input_kvdist.in +++ b/examples/distgen/input_kvdist.in @@ -3,7 +3,7 @@ ############################################################################### beam.npart = 10000 beam.units = static -beam.energy = 2.0e3 +beam.kin_energy = 2.0e3 beam.charge = 1.0e-9 beam.particle = electron beam.distribution = kvdist diff --git a/examples/distgen/input_semigaussian.in b/examples/distgen/input_semigaussian.in index f2d3f1067..93484dc13 100644 --- a/examples/distgen/input_semigaussian.in +++ b/examples/distgen/input_semigaussian.in @@ -3,7 +3,7 @@ ############################################################################### beam.npart = 10000 beam.units = static -beam.energy = 2.0e3 +beam.kin_energy = 2.0e3 beam.charge = 1.0e-9 beam.particle = electron beam.distribution = gaussian diff --git a/examples/expanding_beam/input_expanding.in b/examples/expanding_beam/input_expanding.in index d6a7c526e..23b5546b7 100644 --- a/examples/expanding_beam/input_expanding.in +++ b/examples/expanding_beam/input_expanding.in @@ -3,7 +3,7 @@ ############################################################################### beam.npart = 10000 # outside tests, use 1e5 or more beam.units = static -beam.energy = 250.0 +beam.kin_energy = 250.0 beam.charge = 1.0e-9 beam.particle = electron beam.distribution = kurth6d diff --git a/examples/expanding_beam/run_expanding.py b/examples/expanding_beam/run_expanding.py index 99eb45ef4..cb0e303ef 100755 --- a/examples/expanding_beam/run_expanding.py +++ b/examples/expanding_beam/run_expanding.py @@ -27,13 +27,13 @@ # load a 2 GeV electron beam with an initial # unnormalized rms emittance of 2 nm -energy_MeV = 250 # reference energy +kin_energy_MeV = 250 # reference energy bunch_charge_C = 1.0e-9 # used with space charge npart = 10000 # number of macro particles (outside tests, use 1e5 or more) # reference particle ref = sim.particle_container().ref_particle() -ref.set_charge_qe(-1.0).set_mass_MeV(0.510998950).set_energy_MeV(energy_MeV) +ref.set_charge_qe(-1.0).set_mass_MeV(0.510998950).set_kin_energy_MeV(kin_energy_MeV) # particle bunch distr = distribution.Kurth6D( diff --git a/examples/fodo/input_fodo.in b/examples/fodo/input_fodo.in index b07621ae6..ed2ca40ab 100644 --- a/examples/fodo/input_fodo.in +++ b/examples/fodo/input_fodo.in @@ -3,7 +3,7 @@ ############################################################################### beam.npart = 10000 beam.units = static -beam.energy = 2.0e3 +beam.kin_energy = 2.0e3 beam.charge = 1.0e-9 beam.particle = electron beam.distribution = waterbag diff --git a/examples/fodo/run_fodo.py b/examples/fodo/run_fodo.py index 48f0cb4b7..df60b07a5 100755 --- a/examples/fodo/run_fodo.py +++ b/examples/fodo/run_fodo.py @@ -22,13 +22,13 @@ # load a 2 GeV electron beam with an initial # unnormalized rms emittance of 2 nm -energy_MeV = 2.0e3 # reference energy +kin_energy_MeV = 2.0e3 # reference energy bunch_charge_C = 1.0e-9 # used with space charge npart = 10000 # number of macro particles # reference particle ref = sim.particle_container().ref_particle() -ref.set_charge_qe(-1.0).set_mass_MeV(0.510998950).set_energy_MeV(energy_MeV) +ref.set_charge_qe(-1.0).set_mass_MeV(0.510998950).set_kin_energy_MeV(kin_energy_MeV) # particle bunch distr = distribution.Waterbag( diff --git a/examples/fodo/run_fodo_madx.py b/examples/fodo/run_fodo_madx.py index ae60711ab..34076a905 100755 --- a/examples/fodo/run_fodo_madx.py +++ b/examples/fodo/run_fodo_madx.py @@ -23,7 +23,7 @@ # load a 2 GeV electron beam with an initial # unnormalized rms emittance of 2 nm -energy_MeV = 2.0e3 # reference energy +kin_energy_MeV = 2.0e3 # reference energy bunch_charge_C = 1.0e-9 # used with space charge npart = 10000 # number of macro particles diff --git a/examples/fodo/run_fodo_programmable.py b/examples/fodo/run_fodo_programmable.py index a1980bc93..d8f0cd1fd 100755 --- a/examples/fodo/run_fodo_programmable.py +++ b/examples/fodo/run_fodo_programmable.py @@ -31,13 +31,13 @@ # load a 2 GeV electron beam with an initial # unnormalized rms emittance of 2 nm -energy_MeV = 2.0e3 # reference energy +kin_energy_MeV = 2.0e3 # reference energy bunch_charge_C = 1.0e-9 # used with space charge npart = 10000 # number of macro particles # reference particle ref = sim.particle_container().ref_particle() -ref.set_charge_qe(-1.0).set_mass_MeV(0.510998950).set_energy_MeV(energy_MeV) +ref.set_charge_qe(-1.0).set_mass_MeV(0.510998950).set_kin_energy_MeV(kin_energy_MeV) # particle bunch distr = distribution.Waterbag( diff --git a/examples/fodo_chromatic/input_fodo_chr.in b/examples/fodo_chromatic/input_fodo_chr.in index ef3657dc6..196043892 100644 --- a/examples/fodo_chromatic/input_fodo_chr.in +++ b/examples/fodo_chromatic/input_fodo_chr.in @@ -3,7 +3,7 @@ ############################################################################### beam.npart = 10000 beam.units = static -beam.energy = 2.0e3 +beam.kin_energy = 2.0e3 beam.charge = 1.0e-9 beam.particle = electron beam.distribution = waterbag diff --git a/examples/fodo_chromatic/run_fodo_chr.py b/examples/fodo_chromatic/run_fodo_chr.py index 63892b095..b24c3003b 100755 --- a/examples/fodo_chromatic/run_fodo_chr.py +++ b/examples/fodo_chromatic/run_fodo_chr.py @@ -22,13 +22,13 @@ # load a 2 GeV electron beam with an initial # unnormalized rms emittance of 2 nm -energy_MeV = 2.0e3 # reference energy +kin_energy_MeV = 2.0e3 # reference energy bunch_charge_C = 1.0e-9 # used with space charge npart = 10000 # number of macro particles # reference particle ref = sim.particle_container().ref_particle() -ref.set_charge_qe(-1.0).set_mass_MeV(0.510998950).set_energy_MeV(energy_MeV) +ref.set_charge_qe(-1.0).set_mass_MeV(0.510998950).set_kin_energy_MeV(kin_energy_MeV) # particle bunch distr = distribution.Waterbag( diff --git a/examples/fodo_rf/input_fodo_rf.in b/examples/fodo_rf/input_fodo_rf.in index e0b8e3cda..3835bd6be 100644 --- a/examples/fodo_rf/input_fodo_rf.in +++ b/examples/fodo_rf/input_fodo_rf.in @@ -3,7 +3,7 @@ ############################################################################### beam.npart = 10000 beam.units = static -beam.energy = 250.0 +beam.kin_energy = 250.0 beam.charge = 1.0e-9 beam.particle = proton beam.distribution = waterbag diff --git a/examples/fodo_rf/run_fodo_rf.py b/examples/fodo_rf/run_fodo_rf.py index aaf44e29d..34aef795b 100644 --- a/examples/fodo_rf/run_fodo_rf.py +++ b/examples/fodo_rf/run_fodo_rf.py @@ -23,13 +23,13 @@ # load a 250 MeV proton beam with an initial # unnormalized rms emittance of 1 mm-mrad in all # three phase planes -energy_MeV = 250.0 # reference energy +kin_energy_MeV = 250.0 # reference energy bunch_charge_C = 1.0e-9 # used with space charge npart = 10000 # number of macro particles # reference particle ref = sim.particle_container().ref_particle() -ref.set_charge_qe(1.0).set_mass_MeV(938.27208816).set_energy_MeV(energy_MeV) +ref.set_charge_qe(1.0).set_mass_MeV(938.27208816).set_kin_energy_MeV(kin_energy_MeV) # particle bunch distr = distribution.Waterbag( diff --git a/examples/iota_lattice/input_iotalattice.in b/examples/iota_lattice/input_iotalattice.in index 945d1c063..64325fe5a 100644 --- a/examples/iota_lattice/input_iotalattice.in +++ b/examples/iota_lattice/input_iotalattice.in @@ -3,7 +3,7 @@ ############################################################################### beam.npart = 10000 beam.units = static -beam.energy = 2.5 +beam.kin_energy = 2.5 beam.charge = 1.0e-9 beam.particle = proton beam.distribution = waterbag diff --git a/examples/iota_lattice/run_iotalattice.py b/examples/iota_lattice/run_iotalattice.py index 4a5dbf5e9..dfa06f219 100644 --- a/examples/iota_lattice/run_iotalattice.py +++ b/examples/iota_lattice/run_iotalattice.py @@ -21,13 +21,13 @@ sim.init_grids() # init particle beam -energy_MeV = 2.5 +kin_energy_MeV = 2.5 bunch_charge_C = 1.0e-9 # used with space charge npart = 10000 # reference particle ref = sim.particle_container().ref_particle() -ref.set_charge_qe(1.0).set_mass_MeV(938.27208816).set_energy_MeV(energy_MeV) +ref.set_charge_qe(1.0).set_mass_MeV(938.27208816).set_kin_energy_MeV(kin_energy_MeV) # particle bunch distr = distribution.Waterbag( diff --git a/examples/iota_lens/input_iotalens.in b/examples/iota_lens/input_iotalens.in index 160671dd9..f26f13797 100644 --- a/examples/iota_lens/input_iotalens.in +++ b/examples/iota_lens/input_iotalens.in @@ -3,7 +3,7 @@ ############################################################################### beam.npart = 10000 beam.units = static -beam.energy = 2.5 +beam.kin_energy = 2.5 beam.charge = 1.0e-9 beam.particle = proton beam.distribution = waterbag diff --git a/examples/iota_lens/run_iotalens.py b/examples/iota_lens/run_iotalens.py index c36cff4a3..cbce4158d 100644 --- a/examples/iota_lens/run_iotalens.py +++ b/examples/iota_lens/run_iotalens.py @@ -21,13 +21,13 @@ sim.init_grids() # load a 2.5 MeV proton beam -energy_MeV = 2.5 # reference energy +kin_energy_MeV = 2.5 # reference energy bunch_charge_C = 1.0e-9 # used with space charge npart = 10000 # number of macro particles # reference particle ref = sim.particle_container().ref_particle() -ref.set_charge_qe(1.0).set_mass_MeV(938.27208816).set_energy_MeV(energy_MeV) +ref.set_charge_qe(1.0).set_mass_MeV(938.27208816).set_kin_energy_MeV(kin_energy_MeV) # particle bunch distr = distribution.Waterbag( diff --git a/examples/kicker/input_kicker.in b/examples/kicker/input_kicker.in index f8928918f..9214d4c79 100644 --- a/examples/kicker/input_kicker.in +++ b/examples/kicker/input_kicker.in @@ -3,7 +3,7 @@ ############################################################################### beam.npart = 10000 beam.units = static -beam.energy = 2.0e3 +beam.kin_energy = 2.0e3 beam.charge = 1.0e-9 beam.particle = electron beam.distribution = waterbag diff --git a/examples/kicker/run_kicker.py b/examples/kicker/run_kicker.py index b27c8704c..87458d386 100644 --- a/examples/kicker/run_kicker.py +++ b/examples/kicker/run_kicker.py @@ -22,13 +22,13 @@ # load a 2 GeV electron beam with an initial # unnormalized rms emittance of nm -energy_MeV = 2.0e3 # reference energy +kin_energy_MeV = 2.0e3 # reference energy bunch_charge_C = 1.0e-9 # used without space charge npart = 10000 # number of macro particles # reference particle ref = sim.particle_container().ref_particle() -ref.set_charge_qe(-1.0).set_mass_MeV(0.510998950).set_energy_MeV(energy_MeV) +ref.set_charge_qe(-1.0).set_mass_MeV(0.510998950).set_kin_energy_MeV(kin_energy_MeV) # particle bunch distr = distribution.Waterbag( diff --git a/examples/kurth/input_kurth_10nC_periodic.in b/examples/kurth/input_kurth_10nC_periodic.in index 5cd2ebe8d..5cccabd6f 100644 --- a/examples/kurth/input_kurth_10nC_periodic.in +++ b/examples/kurth/input_kurth_10nC_periodic.in @@ -4,7 +4,7 @@ beam.npart = 10000 #beam.npart = 100000 #optional for increased precision beam.units = static -beam.energy = 2.0e3 +beam.kin_energy = 2.0e3 beam.charge = 1.0e-8 beam.particle = proton beam.distribution = kurth6d diff --git a/examples/kurth/input_kurth_periodic.in b/examples/kurth/input_kurth_periodic.in index 8304ed423..6257f7b7e 100644 --- a/examples/kurth/input_kurth_periodic.in +++ b/examples/kurth/input_kurth_periodic.in @@ -3,7 +3,7 @@ ############################################################################### beam.npart = 10000 beam.units = static -beam.energy = 2.0e3 +beam.kin_energy = 2.0e3 beam.charge = 1.0e-8 beam.particle = proton beam.distribution = kurth6d diff --git a/examples/kurth/run_kurth_10nC_periodic.py b/examples/kurth/run_kurth_10nC_periodic.py index de30b99bd..dcae2fba3 100755 --- a/examples/kurth/run_kurth_10nC_periodic.py +++ b/examples/kurth/run_kurth_10nC_periodic.py @@ -24,13 +24,13 @@ # load a 2 GeV proton beam with an initial # unnormalized rms emittance of 1 um in each # coordinate plane -energy_MeV = 2.0e3 # reference energy +kin_energy_MeV = 2.0e3 # reference energy bunch_charge_C = 1.0e-8 # used with space charge npart = 10000 # number of macro particles; use 1e5 for increased precision # reference particle ref = sim.particle_container().ref_particle() -ref.set_charge_qe(1.0).set_mass_MeV(938.27208816).set_energy_MeV(energy_MeV) +ref.set_charge_qe(1.0).set_mass_MeV(938.27208816).set_kin_energy_MeV(kin_energy_MeV) # particle bunch distr = distribution.Kurth6D( diff --git a/examples/kurth/run_kurth_periodic.py b/examples/kurth/run_kurth_periodic.py index 330f50a04..a1e2c11e8 100755 --- a/examples/kurth/run_kurth_periodic.py +++ b/examples/kurth/run_kurth_periodic.py @@ -23,13 +23,13 @@ # load a 2 GeV proton beam with an initial # unnormalized rms emittance of 1 um in each # coordinate plane -energy_MeV = 2.0e3 # reference energy +kin_energy_MeV = 2.0e3 # reference energy bunch_charge_C = 1.0e-8 # used with space charge npart = 10000 # number of macro particles # reference particle ref = sim.particle_container().ref_particle() -ref.set_charge_qe(1.0).set_mass_MeV(938.27208816).set_energy_MeV(energy_MeV) +ref.set_charge_qe(1.0).set_mass_MeV(938.27208816).set_kin_energy_MeV(kin_energy_MeV) # particle bunch distr = distribution.Kurth6D( diff --git a/examples/multipole/input_multipole.in b/examples/multipole/input_multipole.in index e1fa81c1a..3797c4bce 100644 --- a/examples/multipole/input_multipole.in +++ b/examples/multipole/input_multipole.in @@ -3,7 +3,7 @@ ############################################################################### beam.npart = 10000 beam.units = static -beam.energy = 2.0e3 +beam.kin_energy = 2.0e3 beam.charge = 1.0e-9 beam.particle = electron beam.distribution = waterbag diff --git a/examples/multipole/run_multipole.py b/examples/multipole/run_multipole.py index eb1049238..dadf0d0b3 100644 --- a/examples/multipole/run_multipole.py +++ b/examples/multipole/run_multipole.py @@ -22,13 +22,13 @@ # load a 2 GeV electron beam with an initial # unnormalized rms emittance of nm -energy_MeV = 2.0e3 # reference energy +kin_energy_MeV = 2.0e3 # reference energy bunch_charge_C = 1.0e-9 # used without space charge npart = 10000 # number of macro particles # reference particle ref = sim.particle_container().ref_particle() -ref.set_charge_qe(-1.0).set_mass_MeV(0.510998950).set_energy_MeV(energy_MeV) +ref.set_charge_qe(-1.0).set_mass_MeV(0.510998950).set_kin_energy_MeV(kin_energy_MeV) # particle bunch distr = distribution.Waterbag( diff --git a/examples/positron_channel/input_positron.in b/examples/positron_channel/input_positron.in index 4ddb351ac..407f193b7 100644 --- a/examples/positron_channel/input_positron.in +++ b/examples/positron_channel/input_positron.in @@ -3,7 +3,7 @@ ############################################################################### beam.npart = 10000 beam.units = static -beam.energy = 10.0e3 +beam.kin_energy = 10.0e3 beam.charge = 190.0e-12 beam.particle = positron beam.distribution = triangle diff --git a/examples/positron_channel/run_positron.py b/examples/positron_channel/run_positron.py index f0087a410..c808d09b5 100755 --- a/examples/positron_channel/run_positron.py +++ b/examples/positron_channel/run_positron.py @@ -22,13 +22,13 @@ # load a 10 GeV positron beam with an initial # normalized rms emittance of 10 nm -energy_MeV = 10.0e3 # reference energy +kin_energy_MeV = 10.0e3 # reference energy bunch_charge_C = 190.0e-12 # used with space charge npart = 10000 # number of macro particles # reference particle ref = sim.particle_container().ref_particle() -ref.set_charge_qe(1.0).set_mass_MeV(0.510998950).set_energy_MeV(energy_MeV) +ref.set_charge_qe(1.0).set_mass_MeV(0.510998950).set_kin_energy_MeV(kin_energy_MeV) # particle bunch distr = distribution.Triangle( diff --git a/examples/quadrupole_softedge/input_quadrupole_softedge.in b/examples/quadrupole_softedge/input_quadrupole_softedge.in index 7580752af..30e5fac16 100644 --- a/examples/quadrupole_softedge/input_quadrupole_softedge.in +++ b/examples/quadrupole_softedge/input_quadrupole_softedge.in @@ -3,7 +3,7 @@ ############################################################################### beam.npart = 10000 beam.units = static -beam.energy = 2.0e3 +beam.kin_energy = 2.0e3 beam.charge = 1.0e-9 beam.particle = electron beam.distribution = waterbag diff --git a/examples/quadrupole_softedge/run_quadrupole_softedge.py b/examples/quadrupole_softedge/run_quadrupole_softedge.py index ed0b461c7..882e0e989 100755 --- a/examples/quadrupole_softedge/run_quadrupole_softedge.py +++ b/examples/quadrupole_softedge/run_quadrupole_softedge.py @@ -22,13 +22,13 @@ # load a 2 GeV electron beam with an initial # unnormalized rms emittance of 2 nm -energy_MeV = 2.0e3 # reference energy +kin_energy_MeV = 2.0e3 # reference energy bunch_charge_C = 1.0e-9 # used with space charge npart = 10000 # number of macro particles # reference particle ref = sim.particle_container().ref_particle() -ref.set_charge_qe(-1.0).set_mass_MeV(0.510998950).set_energy_MeV(energy_MeV) +ref.set_charge_qe(-1.0).set_mass_MeV(0.510998950).set_kin_energy_MeV(kin_energy_MeV) # particle bunch distr = distribution.Waterbag( diff --git a/examples/rfcavity/input_rfcavity.in b/examples/rfcavity/input_rfcavity.in index 53c6ef284..dcd41e724 100644 --- a/examples/rfcavity/input_rfcavity.in +++ b/examples/rfcavity/input_rfcavity.in @@ -3,7 +3,7 @@ ############################################################################### beam.npart = 10000 # outside tests, use 1e5 or more beam.units = static -beam.energy = 230 +beam.kin_energy = 230 beam.charge = 1.0e-10 beam.particle = electron beam.distribution = waterbag diff --git a/examples/rfcavity/run_rfcavity.py b/examples/rfcavity/run_rfcavity.py index 61307a9eb..10ee85dc1 100755 --- a/examples/rfcavity/run_rfcavity.py +++ b/examples/rfcavity/run_rfcavity.py @@ -23,13 +23,13 @@ # load a 230 MeV electron beam with an initial # unnormalized rms emittance of 1 mm-mrad in all # three phase planes -energy_MeV = 230.0 # reference energy +kin_energy_MeV = 230.0 # reference energy bunch_charge_C = 1.0e-10 # used with space charge npart = 10000 # number of macro particles (outside tests, use 1e5 or more) # reference particle ref = sim.particle_container().ref_particle() -ref.set_charge_qe(-1.0).set_mass_MeV(0.510998950).set_energy_MeV(energy_MeV) +ref.set_charge_qe(-1.0).set_mass_MeV(0.510998950).set_kin_energy_MeV(kin_energy_MeV) # particle bunch distr = distribution.Waterbag( diff --git a/examples/rotation/input_rotation.in b/examples/rotation/input_rotation.in index ed7cad8bb..a1a27a0e4 100644 --- a/examples/rotation/input_rotation.in +++ b/examples/rotation/input_rotation.in @@ -3,7 +3,7 @@ ############################################################################### beam.npart = 10000 beam.units = static -beam.energy = 2.0e3 +beam.kin_energy = 2.0e3 beam.charge = 1.0e-9 beam.particle = electron beam.distribution = waterbag diff --git a/examples/rotation/run_rotation.py b/examples/rotation/run_rotation.py index 3c4ef2e27..2d47931d8 100644 --- a/examples/rotation/run_rotation.py +++ b/examples/rotation/run_rotation.py @@ -22,13 +22,13 @@ # load a 2 GeV electron beam with an initial # unnormalized rms emittance of nm -energy_MeV = 2.0e3 # reference energy +kin_energy_MeV = 2.0e3 # reference energy bunch_charge_C = 1.0e-9 # used without space charge npart = 10000 # number of macro particles # reference particle ref = sim.particle_container().ref_particle() -ref.set_charge_qe(-1.0).set_mass_MeV(0.510998950).set_energy_MeV(energy_MeV) +ref.set_charge_qe(-1.0).set_mass_MeV(0.510998950).set_kin_energy_MeV(kin_energy_MeV) # particle bunch distr = distribution.Waterbag( diff --git a/examples/solenoid/input_solenoid.in b/examples/solenoid/input_solenoid.in index a91b5a935..66c7cfed0 100644 --- a/examples/solenoid/input_solenoid.in +++ b/examples/solenoid/input_solenoid.in @@ -3,7 +3,7 @@ ############################################################################### beam.npart = 10000 beam.units = static -beam.energy = 250.0 +beam.kin_energy = 250.0 beam.charge = 1.0e-9 beam.particle = proton beam.distribution = waterbag diff --git a/examples/solenoid/run_solenoid.py b/examples/solenoid/run_solenoid.py index 218234e3d..3faef7d04 100755 --- a/examples/solenoid/run_solenoid.py +++ b/examples/solenoid/run_solenoid.py @@ -23,13 +23,13 @@ # load a 250 MeV proton beam with an initial # horizontal rms emittance of 1 um and an # initial vertical rms emittance of 2 um -energy_MeV = 250.0 # reference energy +kin_energy_MeV = 250.0 # reference energy bunch_charge_C = 1.0e-9 # used with space charge npart = 10000 # number of macro particles # reference particle ref = sim.particle_container().ref_particle() -ref.set_charge_qe(1.0).set_mass_MeV(938.27208816).set_energy_MeV(energy_MeV) +ref.set_charge_qe(1.0).set_mass_MeV(938.27208816).set_kin_energy_MeV(kin_energy_MeV) # particle bunch distr = distribution.Waterbag( diff --git a/examples/solenoid_softedge/input_solenoid_softedge.in b/examples/solenoid_softedge/input_solenoid_softedge.in index 94058f7df..d6088592f 100644 --- a/examples/solenoid_softedge/input_solenoid_softedge.in +++ b/examples/solenoid_softedge/input_solenoid_softedge.in @@ -3,7 +3,7 @@ ############################################################################### beam.npart = 10000 beam.units = static -beam.energy = 250.0 +beam.kin_energy = 250.0 beam.charge = 1.0e-9 beam.particle = proton beam.distribution = waterbag diff --git a/examples/solenoid_softedge/run_solenoid_softedge.py b/examples/solenoid_softedge/run_solenoid_softedge.py index 88ec10360..b65e806e2 100755 --- a/examples/solenoid_softedge/run_solenoid_softedge.py +++ b/examples/solenoid_softedge/run_solenoid_softedge.py @@ -23,13 +23,13 @@ # load a 250 MeV proton beam with an initial # horizontal rms emittance of 1 um and an # initial vertical rms emittance of 2 um -energy_MeV = 250.0 # reference energy +kin_energy_MeV = 250.0 # reference energy bunch_charge_C = 1.0e-9 # used with space charge npart = 10000 # number of macro particles # reference particle ref = sim.particle_container().ref_particle() -ref.set_charge_qe(1.0).set_mass_MeV(938.27208816).set_energy_MeV(energy_MeV) +ref.set_charge_qe(1.0).set_mass_MeV(938.27208816).set_kin_energy_MeV(kin_energy_MeV) # particle bunch distr = distribution.Waterbag( diff --git a/tests/python/test_impactx.py b/tests/python/test_impactx.py index 11dbb46cf..390fe5ea8 100755 --- a/tests/python/test_impactx.py +++ b/tests/python/test_impactx.py @@ -76,13 +76,13 @@ def test_impactx_nofile(): sim.init_grids() # init particle beam - energy_MeV = 2.0e3 + kin_energy_MeV = 2.0e3 bunch_charge_C = 1.0e-9 npart = 10000 # reference particle ref = sim.particle_container().ref_particle() - ref.set_charge_qe(-1.0).set_mass_MeV(0.510998950).set_energy_MeV(energy_MeV) + ref.set_charge_qe(-1.0).set_mass_MeV(0.510998950).set_kin_energy_MeV(kin_energy_MeV) # particle bunch distr = distribution.Waterbag( @@ -137,11 +137,11 @@ def test_impactx_noparticles(): sim.init_grids() # init particle beam - energy_MeV = 2.0e3 + kin_energy_MeV = 2.0e3 # reference particle ref = sim.particle_container().ref_particle() - ref.set_charge_qe(-1.0).set_mass_MeV(0.510998950).set_energy_MeV(energy_MeV) + ref.set_charge_qe(-1.0).set_mass_MeV(0.510998950).set_kin_energy_MeV(kin_energy_MeV) # particle bunch: init intentionally missing # init accelerator lattice diff --git a/tests/python/test_transformation.py b/tests/python/test_transformation.py index 8f0e0cb10..60bba3b5f 100644 --- a/tests/python/test_transformation.py +++ b/tests/python/test_transformation.py @@ -38,15 +38,15 @@ def test_transformation(): # load a 1 GeV electron beam with an initial # unnormalized rms emittance of 2 nm - energy_MeV = 1e3 # reference energy - energy_gamma = energy_MeV / 0.510998950 + kin_energy_MeV = 1e3 # reference energy + energy_gamma = kin_energy_MeV / 0.510998950 + 1.0 bunch_charge_C = 1.0e-9 # used with space charge npart = 10000 # number of macro particles # reference particle pc = sim.particle_container() ref = pc.ref_particle() - ref.set_charge_qe(-1.0).set_mass_MeV(0.510998950).set_energy_MeV(energy_MeV) + ref.set_charge_qe(-1.0).set_mass_MeV(0.510998950).set_kin_energy_MeV(kin_energy_MeV) # particle bunch distr = distribution.Gaussian( From 10015d0a776d99a43d5a60158e7bfee2b84c7acf Mon Sep 17 00:00:00 2001 From: Axel Huebl Date: Fri, 20 Oct 2023 10:12:28 -0700 Subject: [PATCH 3/5] Docs: New Kin Energy APIs --- docs/source/usage/parameters.rst | 146 +++++++++++++++++-------------- docs/source/usage/python.rst | 16 ++-- 2 files changed, 90 insertions(+), 72 deletions(-) diff --git a/docs/source/usage/parameters.rst b/docs/source/usage/parameters.rst index d22bb3e11..77d438d71 100644 --- a/docs/source/usage/parameters.rst +++ b/docs/source/usage/parameters.rst @@ -53,6 +53,9 @@ Overall simulation parameters Setting up the field mesh ------------------------- +ImpactX uses an AMReX grid of boxes to organize and parallelize the simulation domain. +These boxes also contain a field mesh, if space charge calculations are enabled. + * ``amr.n_cell`` (3 integers) optional (default: 1 `blocking_factor `__ per MPI process) The number of grid points along each direction (on the **coarsest level**) @@ -114,104 +117,119 @@ Domain Boundary Conditions Initial Beam Distributions -------------------------- -* ``.type`` (``string``) +* ``beam.npart`` (``integer``) + number of weighted simulation particles + +* ``beam.units`` (``string``) + currently, only ``static`` is supported. + +* ``beam.kin_energy`` (``float``, in MeV) + beam kinetic energy + +* ``beam.charge`` (``float``, in C) + bunch charge + +* ``beam.particle`` (``string``) + particle type: currently either ``electron``, ``positron`` or ``proton`` + +* ``beam.distribution`` (``string``) Indicates the initial distribution type. This should be one of: * ``waterbag`` for initial Waterbag distribution. With additional parameters: - * ``.sigmaX`` (``float``, in meters) rms X - * ``.sigmaY`` (``float``, in meters) rms Y - * ``.sigmaT`` (``float``, in radian) rms normalized time difference T - * ``.sigmaPx`` (``float``, in momentum) rms Px - * ``.sigmaPy`` (``float``, in momentum) rms Py - * ``.sigmaPt`` (``float``, in energy deviation) rms Pt - * ``.muxpx`` (``float``, dimensionless, default: ``0``) correlation X-Px - * ``.muypy`` (``float``, dimensionless, default: ``0``) correlation Y-Py - * ``.mutpt`` (``float``, dimensionless, default: ``0``) correlation T-Pt + * ``beam.sigmaX`` (``float``, in meters) rms X + * ``beam.sigmaY`` (``float``, in meters) rms Y + * ``beam.sigmaT`` (``float``, in radian) rms normalized time difference T + * ``beam.sigmaPx`` (``float``, in momentum) rms Px + * ``beam.sigmaPy`` (``float``, in momentum) rms Py + * ``beam.sigmaPt`` (``float``, in energy deviation) rms Pt + * ``beam.muxpx`` (``float``, dimensionless, default: ``0``) correlation X-Px + * ``beam.muypy`` (``float``, dimensionless, default: ``0``) correlation Y-Py + * ``beam.mutpt`` (``float``, dimensionless, default: ``0``) correlation T-Pt * ``kurth6d`` for initial 6D Kurth distribution. With additional parameters: - * ``.sigmaX`` (``float``, in meters) rms X - * ``.sigmaY`` (``float``, in meters) rms Y - * ``.sigmaT`` (``float``, in radian) rms normalized time difference T - * ``.sigmaPx`` (``float``, in momentum) rms Px - * ``.sigmaPy`` (``float``, in momentum) rms Py - * ``.sigmaPt`` (``float``, in energy deviation) rms Pt - * ``.muxpx`` (``float``, dimensionless, default: ``0``) correlation X-Px - * ``.muypy`` (``float``, dimensionless, default: ``0``) correlation Y-Py - * ``.mutpt`` (``float``, dimensionless, default: ``0``) correlation T-Pt + * ``beam.sigmaX`` (``float``, in meters) rms X + * ``beam.sigmaY`` (``float``, in meters) rms Y + * ``beam.sigmaT`` (``float``, in radian) rms normalized time difference T + * ``beam.sigmaPx`` (``float``, in momentum) rms Px + * ``beam.sigmaPy`` (``float``, in momentum) rms Py + * ``beam.sigmaPt`` (``float``, in energy deviation) rms Pt + * ``beam.muxpx`` (``float``, dimensionless, default: ``0``) correlation X-Px + * ``beam.muypy`` (``float``, dimensionless, default: ``0``) correlation Y-Py + * ``beam.mutpt`` (``float``, dimensionless, default: ``0``) correlation T-Pt * ``gaussian`` for initial 6D Gaussian (normal) distribution. With additional parameters: - * ``.sigmaX`` (``float``, in meters) rms X - * ``.sigmaY`` (``float``, in meters) rms Y - * ``.sigmaT`` (``float``, in radian) rms normalized time difference T - * ``.sigmaPx`` (``float``, in momentum) rms Px - * ``.sigmaPy`` (``float``, in momentum) rms Py - * ``.sigmaPt`` (``float``, in energy deviation) rms Pt - * ``.muxpx`` (``float``, dimensionless, default: ``0``) correlation X-Px - * ``.muypy`` (``float``, dimensionless, default: ``0``) correlation Y-Py - * ``.mutpt`` (``float``, dimensionless, default: ``0``) correlation T-Pt + * ``beam.sigmaX`` (``float``, in meters) rms X + * ``beam.sigmaY`` (``float``, in meters) rms Y + * ``beam.sigmaT`` (``float``, in radian) rms normalized time difference T + * ``beam.sigmaPx`` (``float``, in momentum) rms Px + * ``beam.sigmaPy`` (``float``, in momentum) rms Py + * ``beam.sigmaPt`` (``float``, in energy deviation) rms Pt + * ``beam.muxpx`` (``float``, dimensionless, default: ``0``) correlation X-Px + * ``beam.muypy`` (``float``, dimensionless, default: ``0``) correlation Y-Py + * ``beam.mutpt`` (``float``, dimensionless, default: ``0``) correlation T-Pt * ``kvdist`` for initial K-V distribution in the transverse plane. The distribution is uniform in t and Gaussian in pt. With additional parameters: - * ``.sigmaX`` (``float``, in meters) rms X - * ``.sigmaY`` (``float``, in meters) rms Y - * ``.sigmaT`` (``float``, in radian) rms normalized time difference T - * ``.sigmaPx`` (``float``, in momentum) rms Px - * ``.sigmaPy`` (``float``, in momentum) rms Py - * ``.sigmaPt`` (``float``, in energy deviation) rms Pt - * ``.muxpx`` (``float``, dimensionless, default: ``0``) correlation X-Px - * ``.muypy`` (``float``, dimensionless, default: ``0``) correlation Y-Py - * ``.mutpt`` (``float``, dimensionless, default: ``0``) correlation T-Pt + * ``beam.sigmaX`` (``float``, in meters) rms X + * ``beam.sigmaY`` (``float``, in meters) rms Y + * ``beam.sigmaT`` (``float``, in radian) rms normalized time difference T + * ``beam.sigmaPx`` (``float``, in momentum) rms Px + * ``beam.sigmaPy`` (``float``, in momentum) rms Py + * ``beam.sigmaPt`` (``float``, in energy deviation) rms Pt + * ``beam.muxpx`` (``float``, dimensionless, default: ``0``) correlation X-Px + * ``beam.muypy`` (``float``, dimensionless, default: ``0``) correlation Y-Py + * ``beam.mutpt`` (``float``, dimensionless, default: ``0``) correlation T-Pt * ``kurth4d`` for initial 4D Kurth distribution in the transverse plane. The distribution is uniform in t and Gaussian in pt. With additional parameters: - * ``.sigmaX`` (``float``, in meters) rms X - * ``.sigmaY`` (``float``, in meters) rms Y - * ``.sigmaT`` (``float``, in radian) rms normalized time difference T - * ``.sigmaPx`` (``float``, in momentum) rms Px - * ``.sigmaPy`` (``float``, in momentum) rms Py - * ``.sigmaPt`` (``float``, in energy deviation) rms Pt - * ``.muxpx`` (``float``, dimensionless, default: ``0``) correlation X-Px - * ``.muypy`` (``float``, dimensionless, default: ``0``) correlation Y-Py - * ``.mutpt`` (``float``, dimensionless, default: ``0``) correlation T-Pt + * ``beam.sigmaX`` (``float``, in meters) rms X + * ``beam.sigmaY`` (``float``, in meters) rms Y + * ``beam.sigmaT`` (``float``, in radian) rms normalized time difference T + * ``beam.sigmaPx`` (``float``, in momentum) rms Px + * ``beam.sigmaPy`` (``float``, in momentum) rms Py + * ``beam.sigmaPt`` (``float``, in energy deviation) rms Pt + * ``beam.muxpx`` (``float``, dimensionless, default: ``0``) correlation X-Px + * ``beam.muypy`` (``float``, dimensionless, default: ``0``) correlation Y-Py + * ``beam.mutpt`` (``float``, dimensionless, default: ``0``) correlation T-Pt * ``semigaussian`` for initial Semi-Gaussian distribution. The distribution is uniform within a cylinder in (x,y,z) and Gaussian in momenta (px,py,pt). With additional parameters: - * ``.sigmaX`` (``float``, in meters) rms X - * ``.sigmaY`` (``float``, in meters) rms Y - * ``.sigmaT`` (``float``, in radian) rms normalized time difference T - * ``.sigmaPx`` (``float``, in momentum) rms Px - * ``.sigmaPy`` (``float``, in momentum) rms Py - * ``.sigmaPt`` (``float``, in energy deviation) rms Pt - * ``.muxpx`` (``float``, dimensionless, default: ``0``) correlation X-Px - * ``.muypy`` (``float``, dimensionless, default: ``0``) correlation Y-Py - * ``.mutpt`` (``float``, dimensionless, default: ``0``) correlation T-Pt + * ``beam.sigmaX`` (``float``, in meters) rms X + * ``beam.sigmaY`` (``float``, in meters) rms Y + * ``beam.sigmaT`` (``float``, in radian) rms normalized time difference T + * ``beam.sigmaPx`` (``float``, in momentum) rms Px + * ``beam.sigmaPy`` (``float``, in momentum) rms Py + * ``beam.sigmaPt`` (``float``, in energy deviation) rms Pt + * ``beam.muxpx`` (``float``, dimensionless, default: ``0``) correlation X-Px + * ``beam.muypy`` (``float``, dimensionless, default: ``0``) correlation Y-Py + * ``beam.mutpt`` (``float``, dimensionless, default: ``0``) correlation T-Pt * ``triangle`` a triangle distribution for laser-plasma acceleration related applications. A ramped, triangular current profile with a Gaussian energy spread (possibly correlated). The transverse distribution is a 4D waterbag. With additional parameters: - * ``.sigmaX`` (``float``, in meters) rms X - * ``.sigmaY`` (``float``, in meters) rms Y - * ``.sigmaT`` (``float``, in radian) rms normalized time difference T - * ``.sigmaPx`` (``float``, in momentum) rms Px - * ``.sigmaPy`` (``float``, in momentum) rms Py - * ``.sigmaPt`` (``float``, in energy deviation) rms Pt - * ``.muxpx`` (``float``, dimensionless, default: ``0``) correlation X-Px - * ``.muypy`` (``float``, dimensionless, default: ``0``) correlation Y-Py - * ``.mutpt`` (``float``, dimensionless, default: ``0``) correlation T-Pt + * ``beam.sigmaX`` (``float``, in meters) rms X + * ``beam.sigmaY`` (``float``, in meters) rms Y + * ``beam.sigmaT`` (``float``, in radian) rms normalized time difference T + * ``beam.sigmaPx`` (``float``, in momentum) rms Px + * ``beam.sigmaPy`` (``float``, in momentum) rms Py + * ``beam.sigmaPt`` (``float``, in energy deviation) rms Pt + * ``beam.muxpx`` (``float``, dimensionless, default: ``0``) correlation X-Px + * ``beam.muypy`` (``float``, dimensionless, default: ``0``) correlation Y-Py + * ``beam.mutpt`` (``float``, dimensionless, default: ``0``) correlation T-Pt .. _running-cpp-parameters-lattice: diff --git a/docs/source/usage/python.rst b/docs/source/usage/python.rst index 88832378e..2eb145e40 100644 --- a/docs/source/usage/python.rst +++ b/docs/source/usage/python.rst @@ -304,27 +304,27 @@ Particles .. py:property:: px - momentum in x, normalized to proper velocity + momentum in x, normalized to mass*c :math:`p_x = \gamma \beta_x` .. py:property:: py - momentum in y, normalized to proper velocity + momentum in y, normalized to mass*c :math:`p_x = \gamma \beta_x` .. py:property:: pz - momentum in z, normalized to proper velocity + momentum in z, normalized to mass*c :math:`p_x = \gamma \beta_x` .. py:property:: pt - energy deviation, normalized by rest energy + energy, normalized by rest energy :math:`p_t = -\gamma` .. py:property:: gamma - Read-only: Get reference particle relativistic gamma. + Read-only: Get reference particle relativistic gamma :math:`\gamma = 1/\sqrt{1-\beta^2}` .. py:property:: beta - Read-only: Get reference particle relativistic beta. + Read-only: Get reference particle relativistic beta :math:`\beta = v/c` .. py:property:: beta_gamma @@ -342,9 +342,9 @@ Particles Write-only: Set reference particle rest mass (MeV/c^2). - .. py:method:: set_energy_MeV(energy_MeV) + .. py:method:: set_kin_energy_MeV(kin_energy_MeV) - Write-only: Set reference particle kinetic energy. + Write-only: Set reference particle kinetic energy (MeV) .. py:method:: load_file(madx_file) From 6b403c5776578dd07820a1047c10aafcc373cac2 Mon Sep 17 00:00:00 2001 From: Axel Huebl Date: Fri, 20 Oct 2023 10:47:47 -0700 Subject: [PATCH 4/5] Solenoid: Fix 250 MeV Proton MAD-X Example Total energy, not kinetic energy. --- examples/solenoid/solenoid.madx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/solenoid/solenoid.madx b/examples/solenoid/solenoid.madx index 685cc9784..3add05cce 100644 --- a/examples/solenoid/solenoid.madx +++ b/examples/solenoid/solenoid.madx @@ -1,4 +1,4 @@ -beam, particle=proton, energy=0.250; +beam, particle=proton, energy=1.188272; M1: MONITOR,L=0.0; SOL1: solenoid, L=3.820395, KS=0.8223219329893234; From c168af42df980df82b5aa1b6bc9a107d46b05d18 Mon Sep 17 00:00:00 2001 From: Axel Huebl Date: Fri, 20 Oct 2023 14:49:24 -0700 Subject: [PATCH 5/5] Doc: Formatting --- docs/source/usage/python.rst | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/source/usage/python.rst b/docs/source/usage/python.rst index 2eb145e40..5acc023ec 100644 --- a/docs/source/usage/python.rst +++ b/docs/source/usage/python.rst @@ -304,31 +304,31 @@ Particles .. py:property:: px - momentum in x, normalized to mass*c :math:`p_x = \gamma \beta_x` + momentum in x, normalized to mass*c, :math:`p_x = \gamma \beta_x` .. py:property:: py - momentum in y, normalized to mass*c :math:`p_x = \gamma \beta_x` + momentum in y, normalized to mass*c, :math:`p_x = \gamma \beta_x` .. py:property:: pz - momentum in z, normalized to mass*c :math:`p_x = \gamma \beta_x` + momentum in z, normalized to mass*c, :math:`p_x = \gamma \beta_x` .. py:property:: pt - energy, normalized by rest energy :math:`p_t = -\gamma` + energy, normalized by rest energy, :math:`p_t = -\gamma` .. py:property:: gamma - Read-only: Get reference particle relativistic gamma :math:`\gamma = 1/\sqrt{1-\beta^2}` + Read-only: Get reference particle relativistic gamma, :math:`\gamma = 1/\sqrt{1-\beta^2}` .. py:property:: beta - Read-only: Get reference particle relativistic beta :math:`\beta = v/c` + Read-only: Get reference particle relativistic beta, :math:`\beta = v/c` .. py:property:: beta_gamma - Read-only: Get reference particle beta*gamma + Read-only: Get reference particle :math:`\beta \cdot \gamma` .. py:property:: qm_qeeV