JSPEC User Manual
User Manual:
Open the PDF directly: View PDF
.
Page Count: 12

Sectionname Category Usage
section_scratch scratch Definevariablesanddocalculationswiththevariables.Thevariables
definedinthissectioncanbeusedindefinitionsections.
section_ion definition Setparametersfortheionbeam
section_ring definition Setparametersfortheionring
section_e_beam definition Setparametersforthecoolingelectronbeam
section_cooler definition Setparametersforthecooler
section_ibs definition SetparametersforIBSratecalculation
section_ecool definition Setparametersforelectroncoolingratecalculation
section_run operation Createtheobjectives(ionbeam,ionring,electronbeam,cooler)and
performthecalculationand/orthesimulation.
JSPECv.1.0.0UserManual
Usingthetextbaseduserinterface
RunJSPECwiththeinputfile
PuttheinputfileinthesamedirectorywiththeJSPECprogramandrunJSPECas:
jspec.exeinputfile
Formatoftheinputfile
Theinputfileisaplaintextfileanditwillbeparsedbytheprogramlinebyline.Eachcommandorexpression
shouldoccupyaseparateline.Commentsstartwith"#".Everythingbehindthe"#"inthelinewillbeignoredby
theprogram.Blanklines,whitespacesandtabsarealsoignored.TheinputfileisNOTcasesensitive.
Theinputfileisorganizedbyvarioussections.Allthesectionsfallintothreedifferentcategories:(1)scratch
section,(2)definitionsectionsand(3)operationsection.Allthesectionswiththerespectivecategoriesand
usagesarelistedinthefollowingtable.
Theinputfilestartswithasectionbycallingthesectionname.Onceasectionnameiscalled,therespective
sectioniscreated,andthissectionendswhenanothersectionnameiscalledorwhentheinputfileends.
Sectionscanberepeatedcalledandthelatteroneoverwritethepreviousones.Butifaparametersisnotset
againinthelatterone,itsvalueremains.
Thefollowingexampleincludesthreedifferentsectionsinthreedifferentcategories.

Constant Value Meaning
k_c 299792458.0 speedoflight,inm/s
k_e 1.602176565E19; Elementarycharge,inC
k_pi 3.1415926535897932384626
k_u 931.49406121 Atomicmassunit,inMeV/c^2
k_me 0.510998928 Electronmass,inMeV/c^2
k_ke 8.9875517873681764E+9 Coulomb'sconstant,inN*m^2/C^2
section_scratch#scratchsection
m=938.272
ke=8000
gamma=ke/m+1
printgamma
list_const
section_e_beam#definitionsection,definetheparametersforelectronbeam
gamma=gamma
tmp_tr=0.1
tmp_l=0.1
shape=dc_uniform
radius=0.004
current=2
section_run#operationfunction
create_e_beam
Thefirstsectionisascratchsection.Inthissection,threevariables,m,ke,andgamma,aredefined.Thevalues
ofmandkeareassigned,andgammaiscalculatedfromkeandm.Thecalculationissupportedbythemath
parser,muParser.Fundamentalcalculationsandfunctionsaresupported,includingsummation,subtraction,
multiplication,division,squareroot,exponentialfunction,etc.FormoredetailsaboutthemuParser,pleasereferto
http://beltoforion.de/article.php?a=muparser.Thecommand"printgamma"willprintthevalueofgammatothe
screen.Thefollowingcommandwillshowalistofalltheconstantvariablessupportedbythescratchsectionon
thescreen.Alltheconstantvariablesandtheirvaluesarelistedinthefollowingtable.
Thesecondsectionisadefinitionsection,whichsetstheparametersforthecoolingelectronbeam.Inallthe
expressionsinthissection,theleftsideofthe"="signisakeywordinsection_e_beam,whichcorrespondstoa
parameteroftheelectronbeam,andtherightsideisthevaluedassigntothekeyword(theparameter).Thefirst
expressioninthissectionis"gamma=gamma".1Theleftgammaisakeyword,whichrepresentstheLorentz
factoroftheelectronbeam.Therightgammaisthevariabledefinedintheabovescratchsection.This
expressionassignsthevalueofthescratchvariablegammatothekeywordgamma.Pleasenotethatascratch
variablecanbeusedinothersectionstosetthevalueforakeyword,butakeywordcannotbeusedinthesame
way.Akeywordshouldalwaysbeontheleftsideofthe"="sign.Thisisthemostimportantdifferencebetweena
scratchvariableandakeyword.Thefollowingexpressionsassignvaluesforotherparametersoftheelectron
beam,whicharethetransversetemperature,thelongitudinaltemperature,theshape,theradiusandthecurrent
oftheelectronbeamrespectively.Dependingontheshapeoftheelectron,variousparametersneedtobeset.In
thisexample,oneneedstosettheradiusandthecurrentforauniformDCelectronbeam.Othersupported
shapesandtherelatedparameters(keywords)canbefoundinthelistsinthenextchapter.

Thethirdsectionistheoperationsection.Intheoperationsection,onecancreatetheobjectsoftheelements,
calculatetheexpansionrateandperformthesimulation.Inthisexample,wecreateanobjectoftheelectron
beamthathasbeendefinedintheabovedefinitionsection.Pleasenotethatthedefinitionsectiononlyrecords
thevaluesoftheparameters,anelementwillnotbecreateduntiltherespectivecommandiscalledinthe
operationsection.Formorecommandssupportedintheoperationsection,pleasecheckoutthelistinthenext
chapter.
IBSExpansionRateCalculation
TocalculatetheIBSexpansionrate,oneneedstodefinetheionbeamandthering.Thensettheparametersfor
IBSratecalculation.Finally,intheoperationsectioncreatetheionbeamandthering,andcallthecommandto
calculatetheIBSexpansionrate.
section_ion #Definetheionbeam
......
section_ring #Definethering
......
section_ibs #SetparametersforIBSratecalculation
......
section_run
create_ion_beam #Createtheionbeam
create_ring #Createthering
calculate_ibs #CalculatetheIBSrate
Tocalculatethetotalexpansionrate,whichisthesummationoftheIBSexpansionrateandtheelectroncooling
rate,onecancallthecommand"total_expansion_rate"insection_run.
CoolingRateCalculation
Tocalculatethecoolingrate,oneneedstodefinetheionbeam,thering,theelectronbeamandthecooler.Then
settheparametersforcoolingratecalculation.Finally,intheoperationsectioncreatealltherelatedelements
aforementionedandcallthecommandtocalculatethecoolingrate.
section_ion #Definetheionbeam
......
section_ring #Definethering
......
section_e_beam #Definetheelectronbeam
......
sectoin_cooler #Definethecooler
......
section_ecool #Settheparametersfortheelectroncoolingratecalculation
......
section_run
create_ion_beam #Createtheionbeam
create_ring #Createthering
create_e_beam #Createtheelectronbeam
create_cooler #Createthecooler
calculate_ecool #Calculatetheelectroncoolingrate

Keywords Meaning
list_var listallthevariablesthathasbeendefined.
list_const listalltheconstants
list_exp listalltheexpression
print Usethiscommandinformat"printx"anditwillprintthevalueofthevariablexinthescreen
Simulation
OnecansimulatetheevolutionoftheionbeamundertheIBSeffectand/orelectroncoolingeffectduringa
predeterminedtime.Theemittances,momentumspread,bunchlength(forbunchedionbeam),andthetotal
expansionrateinallthethreedimensionswillbeoutputtedintoatextfile.Ifdesired,thecoordinatesofalltheion
samplescanalsobesavedintofiles.Theseparametersaresetinsection_simulation,andthesimulationstarts
whenthecommand"run_simulation"iscalledinsection_run.
section_simulation#Settheparametersforthesimulation
......
section_run
run_simulation #Startsimulation
Keepaconstantbunchlengthoftheionbeaminsimulation
Themomentumspreadoftheionbeamchangesduetotheintrabeamscatteringeffectandtheelectroncooling
effectduringthesimulation,hencethebunchlengthchangesiftheRFvoltageisconstant.However,iftheRF
voltagechangesaccordinglywiththemomentumspread,itispossibletomaintainaconstantbunchlength.
JSPECallowstheusertochoosewhethertokeepthebunchlengthconstantinthesimulation.Whenthebunch
lengthismaintainedconstant,theRFvoltageiscalculatedandsavedintheoutputfile.
Tousethisfeature,oneneedstosettheparameter"fixed_bunch_length"insection_simulationtobetrue.One
alsoneedstosettheparameters,rf_h(harmonicnumber),rf_phi(RFphase),andgammar_tr(transitiongamma)
insection_ring.
section_ring#definethering
...
rf_h=3584
rf_phi=0
gamma_tr=12.46
...
section_simulation
...
fixed_bunch_length=true
Listofsections,keywords,andcommands
section_scratch

Keywords Meaning
charge_number Numberofthechargesoftheion
mass Massin[MeV/c2]oftheion
kinetic_energy Kineticenergyin[MeV]oftheion
norm_emit_x Normalizedhorizontalemittancein[m*rad]oftheionbeam
norm_emit_y Normalizedverticalemittancein[m*rad]oftheionbeam
momentum_spread Momentumspreadoftheionbeam
particle_number Totalparticlenumberforcoastingionbeamortheparticlenumberofonebunchfor
bunchedionbeam.
rms_bunch_length RMSbunchlengthforbunchedionbeamin[m]
Keywords Meaning
lattice Thenameofthefilethatsavesthelattice.ThisfileshouldbeintheMADXoutputformat
(.tfs).
qx Transversebetatrontune
qy Verticalbetatrontune
qs Synchrotrontune
gamma_tr Transitiongamma
rf_v VoltageoftheRFcavityin[V]
rf_h Harmonicnumber
rf_phi RFphasein[2 ]
section_ion
section_ring
section_cooler

Keywords Meaning
length Lengthofthecoolerin[m]
section_number Numberofthecoolers
magnetic_field Magneticfieldin[T]
bet_x Betafunctioninhorizontaldirectionin[m]
bet_y Betafunctioninverticaldirectionin[m]
disp_x Dispersioninhorizontaldirectionin[m]
disp_y Dispersioninverticaldirectionin[m]
alpha_x Alphainhorizontaldirection
alpha_y Alphaininverticaldirection
disp_dx Derivativeofthedispersioninhorizontaldirection
disp_dy Derivativeofthedispersioninverticaldirection
section_e_beam

Keywords Meaning
gamma Lorentzfactorgammaforthecoolingelectronbeam
tmp_tr Transversetemperaturein[eV]
tmp_l Longitudinaltemperaturein[eV]forthecoolingelectronbeam
shape
Electronbeamshape.Choosefromdc_uniform,bunched_gaussian,
bunched_uniform,bunched_uniform_elliptic,dc_uniform_hollow,
bunched_uniform_hollow,bunched_user_defined.
radius Radiusofdc_uniformorbunched_uniformelectronbeamin[m].
current Currentofdc_uniformorbunched_uniformelectronbeam.Forbunched_uniform
beam,setthecurrentasifitisadc_uniformbeamin[A].
length Lengthofthebunched_uniformelectronbeamin[m].
sigma_x RMSsizeinhorizontaldirectionofbunched_gaussianelectronbeamin[m].
sigma_y RMSsizeinverticaldirectionofbunched_gaussianelectronbeamin[m].
sigma_z RMSbunchlengthofbunched_gaussianelectronbeamin[m].
rh Lengthofthesemiaxisinhorizontaldirectionin[m].
rv Lengthofthesemiaxisinverticaldirectionin[m].
r_inner Innerradiusofahollowbeamin[m]
r_outter Outterradiusofahollowbeamin[m]
particle_file Nameofthefilethatsavestheparticlesifthebeamshapeisdefinedas
"bunched_user_defined"
total_particle_number Totalnumberofparticlestoloadfromtheuserprovidedfile
box_particle_number Maximumnumberofparticlesineachchildlessboxwhenconstructingthetree
structure.Defaultis200.
line_skip Numberoflinestoskipwhenloadingparticlesfromtheuserprovidedtextfile.
vel_pos_corr Whethertoconsiderthecorrelationbetweenthevelocityandtheposition.Default
isfalse.
binary_file Whethertheuserprovidedfileisinbinaryformat.Defaultisfalse,whichmeansa
textfile.
buffer_size Buffersizewhenloadingparticlesfromtheuserprovidedbinaryfile.
section_ibs

Keywords Meaning
nu Setthegridnumberinhorizontaldirectionforthe3Dintegration.
nv Setthegridnumberinverticaldirectionforthe3Dintegration.
nz Setthegridnumberinlongitudinaldirectionforthe3Dintegration.
log_c Coulomblogarithm.Iflog_cisset,thentheintegrationinthelongitudinaldirectionisreplaced
bytheCoulomblogarithm.Thustheparameternzisignored.
coupling Transversecouplingrate,rangingfrom0to1.
model ModelforIBSexpansionratecalculation:MartiniorBM.
Keywords Meaning
sample_number Numberofthesampleions.
force_formula Choosetheformulaforfrictionforcecalculation.NowonlysupporttheParkhomchuk
formul,usingforce_formula=PARKHOMCHUK.
section_ecool
section_simulation

Keywords Meaning
time Totaltimetosimulate,in[s].
step_number Totalnumberofsteps.Thetimeintervalofeachstepistime/step_number.
sample_number
Numberofthesampleions.TheparametermustbesetwhenusingtheParticle
modeltosimulatetheIBSexpansionprocesswithoutcooling.Whensettingthis
parameterwithcoolingeffect,the"sample_number"parameterinthe
"section_ecool"willbeoverwrittenbythisvalue.
ibs ChoosetosimulatetheIBSeffectornotbysettingthevalueas"true"or"false".
e_cool Choosetosimulatetheelectroncoolingeffectornotbysettingthevalueas"true"
or"false".
model "RMS"or"Particle"modeltochooseforthesimulation.
output_file Outputfilename
output_interval Theintervalofstepstowriteintotheoutputfile.Defaultisone.
save_particle_interval
Theintervalofstepstosavethe6Dcoordinatesoftheions.Nosavingifthe
valueislessthanzero.Defaultis1.ThisisonlyusefulwhenusingtheParticle
modelinsimulations.
ref_bet_x
TWISSparametersforthereferencepoint.Onlyneededwhenthe"modelbeam"
methodisselectedandtheelectroncoolingeffectisnotincludedinthe
simulation.
ref_bet_y Sameasabove.
ref_alf_x Sameasabove.
ref_alf_y Sameasabove.
ref_disp_x Sameasabove.
ref_disp_y Sameasabove.
ref_disp_dx Sameasabove.
ref_disp_dy Sameasabove.
fixed_bunch_length Maintainaconstantionbunchlength.Defaultisfalse.
section_run

Keywords Meaning
create_ion_beam Createtheionbeam.
create_ring Createthering.Mustcreatetheionbeambeforecallingthiscommand.
create_e_beam Createtheelectronbeam
create_cooler Createthecooler.
calculate_ibs CalculatetheIBSrateandoutputtothescreen.Mustcreatetheionbeamandthe
ringbeforecallingthiscommand.
calculate_ecool Calculatetheelectroncoolingrateandoutputtothescreen.Mustcreatetheion
beam,thering,theelectronbeam,andthecoolerbeforecallingthiscommand.
total_expansion_rate
Calculatethetotalexpansionrate(summationoftheibsrateandelectroncooling
rate)andoutputtothescreen.Mustcreatetheionbeam,thering,theelectron
beam,andthecoolerbeforecallingthiscommand.
run_simulation SimulatetheevolutionoftheionbeamunderIBSand/orelectroncoolingeffect(s).
Example
Inthefollowingexample,aDCelectroncoolerandabunchedprotonbeamisdefined.TheIBSrateandthe
electroncoolingratearecalculated.ThentheevolutionoftheprotonbeamunderboththeIBSeffectandthe
electroncoolingeffectissimulatedfor600seconds.

section_ion #Definetheion(proton)beam
charge_number=1 #Chargenumber
mass=938.272 #Massoftheion
kinetic_energy=8000 #Kineticenergy
norm_emit_x=2.2e‐6 #Normalizedemittanceinhorizontaldirection
norm_emit_y=2.2e‐6 #Normalizedemittanceinvertialdirection
momentum_spread=0.0006 #Momentumspread
particle_number=6.58e11 #Totalionnumber(perbunch)
rms_bunch_length=7 #Rmsbunchlengthofthebunchedionbeam
section_ring #Definethering
lattice=MEICColliderRedesign1IP.tfs #filethatsavesthelatticeofthering
section_ibs#definetheargumentsforIBScalculation
nu=100 #GridnumberinhorizontaldirectionforIBSintegration
nv=100 #GridnumberinvertialdirecitonforIBSintegration
nz=40 #GridnumberinlongitudinaldirectionforIBSintegration
log_c=20.6 #DefineCoulomblogrithm.nzisignoredafterlog_cisdefined.
coupling=0 #Nocoupling
section_cooler #Definethecooler
length=3.4 #Coolerlength
section_number=1 #Numberofcoolers
magnetic_field=0.039 #Magneticfield
bet_x=10 #Twissparameteratthecooler
bet_y=10
#disp_x=0 #Ifthevaluesarezero,thecommandcanbe
omitted.
#disp_y=0
#alpha_x=0
#alpha_y=0
#disp_dx=0
#disp_dy=0
section_scratch #Ascratchsection
m=938.272 #Definevariablemandassignavalue.
ke=8000 #Definevariablekeandassignavalue.
gamma=ke/m+1 #Definevariablegammaandcalculateitsvalue.
section_e_beam #Definetheelectronbeam
gamma=gamma #Lorentzfactor,theright"gamma"isthevariabledefine
above.
tmp_tr=0.1 #Transversetemperature
tmp_l=0.01 #Longitudinaltemperature
shape=dc_uniform #Shapeoftheelectronbeam,DCbeamwithuniformcharge
density
radius=0.004 #RadiusoftheDCelectronbeam
current=2 #Currentis2A
section_ecool #Setparametersforelectroncoolingrate
calculation
sample_number=10000 #Numberofionsamples
force_formula=PARKHOMCHUK #Formulaforfrictionforcecalculation
section_run #Operationsection
create_ion_beam
create_ring
calculate_ibs #CalculatetheIBSrate
create_e_beam
create_cooler

1.Theauthorintendedtowritethisexpressioninthiswayinordertoemphasizethedifferencebetweenascratchvariableandakeyword.However,this
expressionmaybeconfusing.Soitisnotrecommendedtousescratchvariableswiththesamenameofakeyword.↩
calculate_ecool #Calculatetheelectroncoolingrate
total_expansion_rate #Calculatethetotalrate=IBSrate+electroncooling
rate
section_simulation #Setparametersfor
simulation
ibs=on #SimulateISB
effect
e_cool=on #Simulate
electroncoolingeffect
time=600 #Timetosimulate
step_number=600 #Numberofsteps
sample_number=100000 #Numberofionsamples
#save_particle_interval=100 #Savethecoordinatesoftheionsevery
100steps
output_file=simulation_test.txt #Filetosavethesimulationresults
model=particle #Selectthemodelusedin
thesimulation
section_run #Operationsection
run_simulation #Startsimulation