An integrated tool for ion linac design

The initial design phase of an ion linac's front end often requires the use of several software programs, each dedicated to a specific component. These components typically include the ion source, a low-energy beam transmission line (LEBT) equipped with electromagnets, a measurement station, and finally the Radio Frequency Quadrupole (RFQ). Unfortunately, many of the legacy and proven software tools in this field lack user-friendly GUIs and have significant learning curves. In this paper, we present a novel approach: a unified software solution that offers a cohesive GUI and integrates with existing legacy software. This single-software approach not only simplifies the design process but also significantly reduces the time required for design and optimization. Our method has been successfully applied to various design configurations, demonstrating its efficiency in both the learning and design phases, compared to the traditional multi-software approach. In addition, we present DemirciPRO as an illustrative implementation of our unified software approach. This software tool showcases real-world scenarios and comparisons drawn from an ongoing proton linac project. DemirciPRO offers a cohesive user interface for designing an ion source, a Low-Energy Beam Transport (LEBT) line, and, ultimately, a Radio-Frequency Quadrupole (RFQ). Each module is capable of utilizing the output from the preceding one along the beamline. Furthermore, it possesses the capability to trace the trajectories of beam particles through the LEBT line using relevant transport matrices and through the RFQ using the leap-frog method.


Introduction
Ion linacs have been built worldwide for a variety of valuable applications in research, industry and medicine.All ion linacs start with a particle source followed by a focusing section and an initial acceleration system at low relativistic .A full low- linac design, therefore, needs to start an ion source (IS) with correct characteristics such as the beam emittance, followed by a Low Energy Beam Transport (LEBT) Line which should match the output of the IS to the input of the accelerating cavity.Usually LEBT lines also contain some beam diagnostics devices for which adequate physical space should be reserved in the beamline.The next component, the low- accelerating cavity should accept the beam and increase the energy of the particles in an optimum way.Amongst these components, the low- accelerating cavity has the most complicated design.After its invention at Protvino Russia, in 1972 [1], the Radio Frequency Quadrupole (RFQ) has been the low- accelerator of choice in all ion machines.Since 1980s, various design and simulation software programs were developed to further improve its performance.For example the work done at Los Alamos [2] improved the RFQ capture efficiency by almost 60%.Some of the commonly used, (and commercial) RFQ design programs are: Lidos [3], Parmteq [4] and RFQGEN [5].Amongst the above mentioned software, Lidos has an integrated graphical user interface (GUI) and covers the all the steps necessary for RFQ design.However it is limited to RFQ design only and as a software developed decades ago, shows some incompatibilities when used on a modern version of Windows operating system on recent hardware.Similarly, Parmteq requires Windows operating system and Intel CPU architecture.It doesn't have a common GUI but the entire package is made of individual executables which communicate via text based input and output files.Another software relevant to the field is Toutatis [6].Although it can not be used directly for designing an RFQ, it can read the design files originating from Parmteq and perform the RFQ beam dynamics simulations.Therefore one commonly used design approach is to -1 -design the RFQ using Parmteq and to simulate, using Toutatis, various scenarios such as the impact of a modified intervane voltage or of a non-optimal vane geometry.
However, as mentioned above, an ion linac contains other components.Some of these components can be designed by some of these programs.For example Parmteq can also design the LEBT Line [7,8], but does not contain code for IS plasma simulations.The ion source design is typically performed using IBSimu [9] which is a C++ based set of libraries with lots of examples covering different cases.Toutatis can help with the design of the LEBT including a pepper pot meter(PPM) [10] for beam diagnostics via the associated Tracewin program [11].Although there are other diagnostic tools such the Faraday Cup for beam current measurement, the PPM is mentioned here for two reasons: first, with a single PPM measurement one can obtain the beam emittance (and also the beam profile) in both x and y directions.Other similar methods and tools, although maybe more versatile, require scanning the beam.Slit scans with Faraday Cups or wire scanners can be cited as examples in this category.In very stable setups a scan might not be an issue, however especially in early stages of a linac commissioning, we believe that the possibility of comparing consecutive profile and emittance measurements would give hints about the short term ion source stability.A scan would obviously give the same information with a larger time period.Second, since the PPM apparatus requires tuning of the apparatus (e.g. the pepperpot to screen distance) to the expected beam.Therefore, we believe that having the possibility to design a PPM and evaluate is capabilities via simulations is beneficial to the designers.A survey of the some of the available software in the field shows that there is no single program that would cover the ion linac design from IS to RFQ including the simulation of the diagnostics tools while offering a unified GUI.
Since 2013, we have been developing new software in this field: DemirciPRO.It features an integrated graphical user interface (GUI) tailored for designing the front-end of an ion linac, spanning from the ion source (IS) to the exit of the Radio-Frequency Quadrupole (RFQ) and, if needed, including the Pepper-Pot Measurement (PPM).Table 1 presents a comparison of DemirciPRO with similar software in terms of their design and simulation capabilities.Among these front-end linac components, the RFQ presents a unique case: while a basic design and simulation can be accomplished using a simple two-term potential, a realistic simulation necessitates the beam dynamics (RBD) simulations under the eight-term potential.Therefore, the RFQ has two columns in the table, one for design and another for RBD simulations.As previously discussed, Toutatis makes this distinction; it cannot perform RFQ design but excels in RBD.
DemirciPRO has long been employed for RFQ design and RBD, utilizing electromagnetic fields obtained from the 3D finite element analysis of the design [12].Its particle tracking in the RBD module is based on the Particle-In-Cell (PIC) approach.More recently, modules for IS and Low-Energy Beam Transport (LEBT) design, including a Pepper-Pot-based emittance measurement station simulation, have been added.This expansion makes DemirciPRO a unique software capable of handling design and simulation tasks related to front-end ion linac design.Tracking in the LEBT module is based on the transfer matrix approach and does not yet incorporate space charge effects.
DemirciPRO also acts as a bridge between various design and simulation programs, capable of converting design files from one format to another.Moreover, it can execute some of these simulation tools, allowing for direct comparisons.We assert that this unified approach simplifies the overall learning curve and streamlines the design process.

Code IS LEBT Magnet PPM RFQ RBD GUI
−: not available, * : with Tracewin support, + ′ : with IBSimu integration, + ′′ : with SuperFish integration, + * in 2D only the complete suite for front-end ion linear accelerator design can be obtained by contacting the authors (email: info.demirci@gmail.com).This paper delves into the details of these new modules, their implementation, and their validation.It also showcases examples from the ongoing "Proton Testbeam At KAHVELab" linac project (PTAK) (see [14] for project details and comparisons between measurements and simulations).
The PTAK project aims to construct an educational proton beamline in Istanbul, Turkey, with the goal of training the next generation of accelerator physicists and engineers on the job and accumulating operational knowledge.The PTAK beamline consists of a microwave discharge ion source, a LEBT section, and a high-frequency RFQ operating at 800 MHz.The RFQ is a compact cavity with a diameter of 130 mm and a total length of 980 mm.The required total normalized emittance at the entry is estimated to be approximately 0.155 • mm•mrad, slightly less than CERN's PIXE RFQ (0.2 • mm•mrad) [15].At present, the PTAK proton beam is commissioned up to the RFQ, which has been constructed and is currently undergoing vacuum and electromagnetic tests.The simulation starts by constructing the volume with imported electrode files and defined mesh sizes.Next step is to render a discrete version of this volume with a rectangular mesh.The potential distribution is solved using Poisson's equation after considering the ion source (IS) geometry, electrode potentials and the boundary conditions.First, the particle trajectories are calculated; second, then the space charge effect on the beam is propagated to the mesh nodes and it is taken into account while solving the electric potentials iteratively.This chain is repeated until the solution converges [17].

DemirciPro IS module
DemirciPro provides an effective solution to the ion source design problem by seamlessly integrating with the IBSimu libraries.The user-friendly interface is displayed in the Ion Source (IS) tab, as seen in figure 1.It includes all the parameters and options mentioned in the ion source examples, including particle charge and mass, which can be adjusted according to the design requirements.This configuration can be saved and reloaded as needed, enabling efficient optimization and focusing on simulation specifics.
The user interface also emphasizes practicality in IS configuration, providing boundary conditions warnings through pop-up notifications.Boundary voltages are adjustable via the left-hand panel, with the ion insertion point as the first boundary.For negative ion sources, the interface enforces the Dirichlet boundary condition, while it implements the Neumann boundary condition for positive ones.These conditions align with the recommendations in the IBSimu reference manual [17].The impact of electrode geometry on the beam is profound.To accommodate different electrode designs, the IS module supports the upload of electrode geometries in DXF format.Each electrode's location -4 - along the beam axis (cm), rotation angle (degrees) around the radial axis, and electric potential (V) can be configured using the GUI.Although the module does not contain the means to draw the electrodes, most of the freely available CAD tools permit saving in this two dimensional format.Furthermore, the package includes several electrode definition files, similar to the ones shown in figure 1, to facilitate a quick start with the design.This feature is particularly beneficial for intricate geometries that are challenging to define analytically.The GUI expects electrode designs to adhere to cylindrical symmetry, which can be selected from a drop-down list box (figure 2).Cylindrical coordinates are the default in simulations, largely due to their prevalent use in ion source designs and their computational efficiency when solving Poisson's equation.
Finally, the module includes a set of configuration and monitoring tools, as well as ion beam simulation results in cylindrical coordinates.It generates an output that includes the - view of the electric field, the beam profile, and extracted beam information in DST format [6].
The preview of selected electrode geometries and their positions in cylindrical coordinates can be seen in the upper right section of the figure 1.The lower section shows the simulation results that are plotted as a function of extracted beam current density.The green progress bar indicates the completed percentage of the running simulation.An external magnetic field file can also be defined and imported in DemirciPro.Such a field map can be incorporated into the simulation by selecting a magnetic field map file using the drop-down list in the dark gray section of figure 1.There may be a residual magnetic field in the extraction zone of the ion source due to the magnetic field applied around the plasma chamber, the selected map file can be used to represent that residual field, or alternatively, the designer may simply want to apply a magnetic field in the extraction region of the ion source for testing purposes.The magnetic field map file is basically a 4 column tab-separated text file, defining the z [m], r [m], Bz [T], and Br [T], representing the position along the beamline, radial position, axial magnetic field strength and radial magnetic field strength, respectively.
IBSimu can export the beam data at the desired position in an output file.This file would be used as an input to a design software such as Travel/Path Manager [18], and the results would finally be represented with a graphics tool such as PlotWin [19].DemirciPRO shortens this procedure by providing the necessary functions and a single user interface to these tasks.Users have the option to designate a specific point along the z-axis for ion beam extraction.At this point, the system exports beam data, or particle information, in both DST and TXT file formats.The TXT file, a tab-separated text document, offers a user-friendly way to review the 6D particle information.Meanwhile, the DST file format, which is a binary file, is a standard format commonly utilized in this field.The -5 - TXT writer in DemirciPRO is based on export_path_manager_data function in IBSimu, whereas the DST writer was independently developed.
To ensure the correct operation of DemirciPro IS module, it was compared to the standalone version of IBSimu using the same electrode and parameter configuration.Then, the same extraction geometry was implemented in both Travel/Path Manager and DemirciPro to compare the beam behaviour under the conditions without the space charge effects.The simulations were performed for 10 data points along the z axis with about 500'000 particles.Since the problem has cylindrical symmetry, the RMS beam envelope in r direction is considered as a figure of merit.Figure 3 shows that the relative difference for the beam envelope along the beamline is less than 0.3 permille.This difference is negligible and can be attributed to different random number seeds, different compiler options etc.It is also known that there are small differences in the RMS values between the exported Path Manager outputs in cylindrical coordinates due to the nature of randomized phase and azimuthal angle.The Relative Difference (RD) was calculated with respect to standalone IBSimu values as:

Designing a low energy beam transport line
The Low Energy Beam Transport (LEBT) line serves a crucial role in ion beam transfer from the Ion Source (IS) to the Radio Frequency Quadrupole (RFQ).This transfer process involves calibrating the ion beam's diameter and emittance to match the RFQ's acceptance parameters.Typically, the LEBT line includes beam tuning components such as steerer magnets, alongside diagnostic tools like emittance measurement instruments.A minimum of two electromagnetic lenses are indispensable to refine the beam within the LEBT line, thus enhancing transport efficiencies.The central objective involves matching the Twiss parameters (, ) in both  and  directions to their RFQ counterparts.Such alignment leads to a high beam acceptance at the RFQ entrance.
The LEBT lines exist in two types: electrostatic and magnetic.However, the particle optics remain identical across both kinds.Electrostatic LEBT lines consist of various electrodes, and their simulation is achievable through IBSimu [16].Magnetic LEBT lines comprise solenoid, quadrupole, dipole, and steerer magnets, determined by the specific requirements of the facility [20].Particularly -6 -in high current beam lines, magnetic LEBT configurations tend to utilize two solenoid magnet systems or Einzel lenses more frequently than quadrupole magnets [21,22].
DemirciPro has an integrated magnetic LEBT design and simulation module based on hard edge model of magnets.Currently, it considers solenoid, quadrupole and dipole fields.Although In magnetic LEBT lines, solenoids are often used, there are specific cases where quadrupoles were used(e.g.[23]).DemirciPro contains the 4-dimensional solenoid transport matrix, including the entry and exit fringe field effects [24].For each magnet, apart from position and field strength, the physical (real) and the effective lengths are to be specified.The solenoid effective length is calculated as: with  eff =  max that refers to field at the solenoid center, i.e. the maximum longitudinal solenoid component   .
The ion beam can either be randomly generated based on user-defined Twiss parameters or imported from an IS simulator in either DST or TXT formats.In the first case, the user can also specify the number of macro particles to be generated and tracked, whereas in the second case, all particles read from the beam definition file are used.The beam pipe's diameter is employed to calculate beam losses, while step sizes govern calculation accuracy.At each step the particles are moved using the transport matrices, particles hitting the beam-pipe walls are removed and the relevant quantities like the Twiss parameters and emittance values for both  and  directions are recalculated and reported.This is somewhat different than solely matrix based approach in other software (e.g.Travel) where transport matrices are used to trace the beam envelope and other Twiss parameters without actually moving the particles.All parameters of the LEBT configurations can be saved and recalled using the integrated GUI.These configuration parameters together with the values from an ongoing LEBT line design can be found in figure 4 left panel.
The simulation moves each particle from the beginning of the LEBT line towards its end where one usually expects an RFQ.At each step, each particle's position in the 4-D phase space is determined using the transfer matrix relevant to the type of space the particle is crossing: drift, solenoid, quadrupole or dipole.Although the current version does not take the space charge effects into account, and this effect is planned to be incorporated as the work is ongoing.For a realistic simulation it is obvious that the step size should be set as small as possible.However, depending on the number of tracked particles, this can consume some large CPU time.For example, a run with 100000 particles with a step size of 1 mm took about 12 seconds on an Intel-i7 CPU laptop.It is therefore possible the adjust separately the step-size in general drift areas and in the region just before the RFQ.The simulation results are the beam distributions in  ′ − ,  ′ −  and  −  at the end of the LEBT line, beam envelopes in both - and - planes both visually at the top and as a histogram.The particles hitting the beampipe walls are assumed lost and removed from tracking.
A typical simulation result can be observed in figure 4 right panels and the simulation parameters on the left.The beam distributions at the top are for  = 128 cm, a location slightly after the beam waist to better observe it in the envelope graph at the rightmost middle section.The lower rightmost graph gives the percentage of lost particles along the beam axis; in this example there are no losses.In the beam distributions, the fitted black ellipses show the RMS section of the beam.To guide the eye in the visual representation, the solenoid magnets are shown in green (physical size in blue), -7 - deflection magnets in gray and the measurement station in black.The measurement box is a device which typically contains elements like a scintillator screen, a Faraday Cup and an emittance meter which will be covered in the next section.
Although all particles are tracked, it is hard to visualize root mean square (RMS) and 100% emittance behaviours at once.For this reason, two different beam envelopes, named inner and outer, are defined and plotted for  −  and  −  planes.The beam envelopes are defined via the RMS distributions, and the decision for selecting the quantile number for both inner and outer values is left to the LEBT designer.As an example, one can see from figure 4 that  = 1 (inner) and  = 6 (outer) RMS envelopes were selected.As usual,  = 1 represents 39% of the beam,  = 6 correspond to about 95% and finally  = 10 to about 99%.Having two different envelopes helps the designer to better estimate the beam behaviour, especially to see which portion of the beam halo would hit the beam pipe.In this particular example, the beam outer envelope approaches the beampipe of (radius=2.5cm) at around 97 cm along the  axis.The  and  beam envelopes along the beam direction () are also shown as a histogram on the rightmost graph.In this particular example the inner envelope is in red, and the outer one is in black.As an option, it is also possible to record the beam in DST format at different locations along the LEBT and compare to other beamline simulation programs.The DST contents can be viewed with standard programs such as Plotwin [19].
One of the software programs commonly used for magnetic LEBT line simulations is Travel/Path Manager [18,25].This software can simulate the beamline both with and without the space charge -8 -  effects.Therefore, a comparison can be made between this well established software and DemirciPro to validate the latter, in the absence of the space charge effects.For the validation test, the simulation of a LEBT line, defined in table 2, was performed with about 100000 particles described in a file exported by IBSimu.To ensure a valid comparison, the same input file was used in both programs.Drift and exit step sizes were set as 1 mm for this comparison.As seen in figure 5 upper part, the computed RMS beam envelope in the radial direction is in agreement between DemirciPRO and Travel at various locations along the beam axis, with the largest difference being approximately 2.4% at the beam waist.Studies conducted with different step size and number of particles have shown that the difference originates mainly from the different values of constants between the two software programs.For example setting in DemirciPRO the speed of light to be 0.3 m/ns (instead of 0.2998 which is DemirciPRO's default) reduces the maximum difference to 1.2% again at the beam waist.
-9 - The same figure, lower part contains a similar comparison with another well known software, TraceWin [6].It can be observed that the largest relative difference, this time taken with respect to TraceWin, is about 0.12% at around the beam waist.The space charge effects in TraceWin were turned off by setting the beam current to 0 mA.Naturally, a comparison between TraceWin and Travel was also made to find a 2.5% difference again around the beam waist region.An independen study on CERN's Linac4 beamline compares these two programs and reports about 4% difference in beta functions at the end of the Chopper Line [26] when the beam current is again taken as 0 mA.We therefore believe that DemirciPro yields somewhat accurate results in conditions where space charge effects are minimally influential.

Poisson Superfish integration
As part of the DemirciPro LEBT subsystem, it is possible to make a realistic magnet design by interfacing with the Poisson-Superfish software suite [27].This suite is a collection of programs for calculating static magnetic and electric fields and radio frequency electromagnetic fields in axial symmetrical cylindrical coordinates.It also contains graphic display tools and other similar codes to show the obtained results in a variety of ways.Although the suite is only for Windows OS and Intel CPUs, it is possible to run the executables on computers sharing the same CPU and running a POSIX-compliant operating systems, such as Linux, MacOS and BSD.This is achieved using the freely available compatibility layer named WINE [28].However, the impact of running software through WINE on a non-Windows operating system has not been evaluated at this time in terms of potential issues related to floating-point calculations.If the designer wishes to stay within the Windows OS, the windows subsystem for Linux (WSL) layer can be used to install a Linux distribution, to utilize all the necessary Linux applications and libraries such as ROOT.The interface to this suite is available through the SFish button (figure 4) on the left side of the LEBT design screen.The target magnet, as previously discussed in LEBT design part, can be either a quadrupole or a solenoid.When a magnet type is selected from the menu, the design parameters are displayed in the next window.An example for the solenoid design can be found in figure 6.The magnet physical dimensions, the coil current and the core material type can also be configured.
The magnetic field inside a solenoid is designed to be approximately uniform; however, on the outside, it is weak and divergent.In order to obtain a symmetrical field distribution, the left and right coils are considered to be identical but the current flow directions differ according to the design.Figure 7 shows the magnetic field distribution for the example design in figure 6.The red (green) curve represents the field in  () direction.
The magnetic field in a quadrupole has two components showing a configuration with hyperbolic pole shapes in the perpendicular plane.The parameters of the geometry for quadrupole design are given in figure 8, left side.On the user interface, the button with the question mark sign provides the skew quadrupole and normal quadrupole magnet definitions.Both configurations are written on files with sf extensions: quadrupolnx.sf(normal) and quadrupolrx.sf(rotated or skew).These files can be run with the SuperFish programs to obtain the magnetic field distributions.It is crucial to have a proper magnetic field distribution to correctly focus the ion beam.This implies a symmetrical field around the coils and zero field at the center as shown in figure 8, right side.For a beam of positively charged ions (or protons) directed towards the reader, such a quadrupole magnet focuses the beam in the vertical direction and defocuses it in the horizontal direction.When this quadrupole magnet is -10 -

Measurement box design
While building a beamline, one of the important goals is being able to characterize the beam properties.The typically measured quantities are the beam charge, the beam profile and the beam emittance.The beam charge is typically measured with a Faraday Cup, a destructive measurement, which could be purchased according to one's budget and expected beam properties.On the other hand, the setup for measuring the beam profile and emittance usually depends on the LEBT line and has to be specific to the designed beamline.DemirciPro offers an integrated section for designing a pepper pot and scintillatorbased setup [10] for measuring these properties.A python version of the algorithms described below were actually used in the PTAK beamline to both estimate the measure the beam emittance.The estimated value was 0.031 •mm•mrad for both  and  directions due to cylindrical symmetry.The experimental results were 0.029 •mm•mrad in  and 0.033 •mm•mrad in  directions [14].These numbers correspond to about 6.5% difference between prediction and measurement.Deeming this result satisfactory, further systematic studies such as the screen alignment tolerances were postponed.
This module uses the beam simulated in the LEBT module which needs to be run beforehand.The beam arriving at the measurement box is tracked inside it, using the same tracking engine towards the pepper pot plate.Depending on the configuration, the pepper pot plate allows a limited number of particles to pass, thus forming beamlets necessary for the emittance measurement setup.These beamlets then hit a scintillating screen, causing it to emit light which is captured by a camera.The camera, installed over a peephole, sees the scintillator through a plane mirror placed inside the measurement box.The picture obtained in the camera is later analyzed to deduce the beam parameters.A schematic representation of this setup is shown in figure 9.Although there are alternative methods for measuring the beam emittance, (such as the three-screen method), in the most recent version of DemirciPRO, based on the past experience of the authors, only the pepper pot measurement design is provided.

Simulation
The design procedure starts by defining the position of the pepper pot plate (PPP) with respect to the beginning of the LEBT line.The second parameter to be defined is the distance between the PPP and the scintillating screen.These two, along with other geometrical parameters of the PPP (such as the number and radius of the holes) are to be entered using the left side of the design window similar to other tabs in DemirciPro.The GUI provides minimal help and default values for all parameters.
-12 - Additionally, the whole measurement box setup, i.e. all relevant parameters can be saved and later reloaded using the appropriate GUI buttons, shown in figure 10.The next set of parameters are related to the visualization of the simulated measurements: the bin counts and limit values of the histograms in physical and angular coordinates.
Once these are defined, the designer can simply simulate the proton beam going through the PPP and illuminating the scintillating screen.The results of such a simulation with 5 million events is shown in figure 10.When the simulation is finished, six plots (as a 2x3 matrix) are shown to the designer: the upper plot of the leftmost column shows the initial beam as it is entering the measurement box, and the lower one the same beam right before hitting the PPP.The designer can check the enlargement of the beam spot using these two plots, as the PPP method is only suitable for divergent beams.The protons surviving the PPP are shown as they are exiting the plate on the top row middle plot, and as they are hitting the scintillating screen on the same row, right plot.While the simulation is user selectable between X&Y directions using the GUI, the program is set up to display and analyze only one of them at a time.Using the values from the simulation, the phase space of the beam, right before hitting the PPP is shown in the lower row middle plot whereas right after the PPP in the same row right plot.The plots are all calculated using full information from the beam data and the resulting histograms are saved into a ROOT file for further analysis.The text output section on the lower left side contains some summary information related to the simulation.These are a number of emittance and Twiss parameter values calculated at different stages of the simulation.Those parameters are written as   , ,  (for normalized emittance, Twiss parameters alpha and beta) for brevity.The "ideal" values are obtained by using all particles hitting the PPP; the "detected" values take into account the fact that the image detector (CCD camera) has a finite resolution due to its CCD pixel sizes.The CCD pixel size is obtained from the histogram parameters and it is represented by the value delta .In example shown in figure 10 it is 50 μm.From this point onward only the histogram bin center values are used as position information.The next set of values are called "holed" since only particles which were able to pass through the holes of the PPP are used in these calculations.Finally, the "measured" values are calculated at the scintillator screen, i.e. after some designer defined drift distance.
DemirciPro updates the LEBT window to show the locations of the PPP and scintillator screen inside the measurement box.The remaining part of the procedure is to analyze that data as if it were coming from a real measurement and to get the emittance values as close as possible to the ones calculated by the simulation part of the program.

Analysis
The analysis of the image obtained from the scintillation screen is performed using the two dimensional image obtained in the simulation stage.The algorithm analyzes the image as if the particle positions and angles were not known.This algorithm can easily be adapted to a real photo of the beamlets by converting the image to a 2D histogram.The analysis procedure consists of taking a projection of the 2D histogram along the  or  directions to end up with a 1D histogram containing beamlet peaks.A peak finder (provided by ROOT library) determines the peak positions to fit a Gaussian function to each beamlet.The user can use the GUI to either fit each beamlet individually or all at once.If the number of simulated particles is not large enough, some regions of the scintillator screen receive less than ideal number of hits to create a reasonable distribution suitable to fitting.For this reason, it is possible to define a threshold value in DemirciPRO, below which the peak candidates are not considered.A possible cure to such a problem would be to re-bin the 1D histogram, loose some details of the beamlet distributions but gain on the number of hits.This possibility is also provided via the GUI.During the fit, the initial values for the peak position and peak intensity are provided automatically by the peak finder function.The remaining parameter, the fit width can be defined via the DemirciPRO GUI.Once the fit is over, the beam emittance and other Twiss parameters can be calculated based on the available information.The program calculates the RMS emittance, however -14 - since the ion type and energy is known, it reports the normalized emittance value: where  and  are relativistic functions,  ℎ refers to the hole center positions in the selected direction ( or  ) and finally  ′ is obtained from the analysis.Using the fact that the hole diameter is very small compared to the PPP to scintillator screen distance (), the angle  ′ can be approximated as: where  (ℎ) is the position of each bin center in the beamlet distribution.The counts in each bin, i.e. number of protons passing through the particular hole ℎ and hitting that bin can be obtained either from the actual data or using the Gaussian fit function.The emittance value is estimated using the averages in equation (4.1) by summing on all holes or peaks above the user defined threshold value.The output from a typical run is shown in figure 11.Among the three plots, the left one shows the individual beamlet distributions zoomed to a particular section of the image, the central one shows the same beamlet intensity distributions together with the Gaussian fit functions overlaid in red, the red triangles show the beamlet intensity peak positions.The right graph shows the emittance plot.The full information using the protons that survived the PPP is shown in red, whereas the simulated experimental results from the scintillating screen are in blue.Note that the beamlet peaks below the pre-determined threshold are not taken into account, leaving some outlaying hole regions without corresponding measurement.The numerical results from this simulated measurement is shown on the leftmost frame:   = 0.0231.mm•mrad.This value is to be compared to the full information at various stages of the simulation as discussed in the previous section.
The effects of changing the number of sigmas of the Gaussian fits to consider, or other similar analysis parameters are to be explored by the PPP designer.Such an example study is presented in table 3, where the image from the simulation in the previous section is studied for an -direction emittance measurement.Recalling its true value of 0.026 mm•mrad, the best relative error for this scenario is about 2%.

RFQ design
The details of the RFQ design procedure via graphical means was previously discussed elsewhere [29].
To give a short summary, the RFQ module starts with a simple design using the two-term potential and calculates the essential parameters such as final beam energy, total RFQ length, Killpatrick limit etc.It also calculates the realistic design parameters with the eight-term potential.It can simulate the particle beams motion within the RFQ using the fields obtained using the finite element analysis technique.As part of the presented integral solution, the RFQ design module can either generate the particle beam according to the designer's selected TWISS parameters or can load the particle beam obtained at the end of the LEBT section.The RFQ design procedure is also GUI based: the designed needs to specify only the start, finish and change points on the modulation, phase, aperture and voltage curves via some anchor points (also called reference cells, could be as few as 7 or 9); then interpolate between these anchor points to find the remaining values of the parameters as functions of cell numbers.Previously, the interpolation was achieved assuming a linear function.This method showed room for improvement, particularly when dealing with rapidly generated test designs that have a relatively small number of reference cells.Therefore, interpolation functions of GNU Scientific Library (GSL) were recently implemented.GSL's interpolation functions offer seven different interpolation types.Out of these seven types, Steffen's Method [30] was found to be the most suitable for this application since it ensures the monotonicity between reference cells and continuity of the resulting function as well as its first derivative.For better user experience interpolation results are presented to designer on a popup window.This method has been tested successfully on several configurations.The above mentioned four parameter functions (of the cell number) together with some fixed variables such as the operating frequency and input beam energy define the RFQ uniquely.Although this procedure has proven itself useful in the past [29], an automatization is expected to speed up the procedure.However different RFQ designs might have different goals: while one RFQ might aim maximum transmission, another might require reaching the target energy at the shortest cavity length.These different scenarios can be covered by defining a versatile  2 function to be minimized: where  is exit energy (MeV),  is the RFQ length (cm) and   is the Kilpatrick bravery factor.The symbols with the subscript  refer to the target value of the corresponding variable.The greek letter coefficients are used for giving relative weights to target values.However the third coefficient, denoted as  plays a crucial role in the RFQ definition.If the surface field of the RFQ under consideration surpasses the envisaged value, this coefficient exhibits a magnitude significantly larger than other terms in the  2 expression.The purpose of this term is to emphasize the importance of not causing RF breakdown inside the RFQ cavity.The minimization is achieved using the Minuit minimization -16 -package from CERN using MIGRAD and MINOS routines.The number of parameters to find during the minimization defines the difficulty level of the problem.To reduce the compute time the current procedure limits the number of anchor points to 15: one for the intervane voltage which is kept constant, seven for the modulation curve and seven for the RF phase curve.The aperture curve is automatically defined since /0 is also kept constant.In this context, the parameter  represents the tip radius and 0 the bore radius.An example optimization for the shortest RFQ length takes about 70 seconds on a 3.2 GHz processor.

Conclusions
This paper identifies a crucial need for a comprehensive approach that integrates various facets of the ion linac design process, including the design of the ion source, low energy beam transport with detailed diagnostics and magnets, and the radio frequency quadrupole.The solution we present, a unified tool with a common GUI can handle the majority of these tasks autonomously.When the task's difficulty surpasses the abilities of the tool, legacy software from the field can be employed, either by directly linking to their libraries or utilizing the corresponding executables when the source code is not available.The utilization of legacy Windows programs can be achieved via the WINE compatibility layer on unix-like operating systems, and WSL allows the operation of Linux software on Windows OS.Furthermore, such a unified tool eases interactions and comparisons among these legacy programs through automated configuration file creation.
To put these concepts into practice, we developed DemirciPRO, an integrated design and simulation tool.DemirciPRO unites an ion source, a LEBT, a PepperPot, and an RFQ module under one cohesive user interface.We carried out a comparative analysis of the ion source and LEBT modules, benchmarking them against established reference software and using the beam envelope as a figure of merit.The IS module is shown to be compatible within 0.03% with the standalone version of IBsimu.The LEBT module is shown to be compatible with Travel when space charge effects are not considered.The maximum difference between these two occur at the beam waist and it is about 2.5%.We believe that this difference arises from variations in the precision of the constants used in these two programs.The work is ongoing for adding space charge effects into DemirciPRO.
The ongoing commissioning work of the proton test beam, PTAK [14] at KahveLab also serves the purpose of validating its results.The solenoids and the LEBT line designed using the DemirciPRO LEBT module have been constructed and commissioned.The axial and transverse magnetic field measurements were found to be compatible (few percent) with the design, the beam spot size, measured at different locations along the beamline has been found as predicted by the design.The beam current measured in a Faraday cup has been found consistent with the predictions from the IS module.The designed pepper-pop plate has been used in emittance measurements yielded results agreeing with the design values.As the software development continues, refinements such as the addition of space charge effects will be considered in the future.
In conclusion, our work has underscored the immense value of leveraging a combined tool with a GUI, particularly for those newly entering the scientific field or students beginning their research journey.This tool streamlines the process of tracking IS, LEBT, RFQ, and magnet designs through an array of text-based configuration files, fostering a comprehensive understanding of the design elements.The inclusion of various 2D and 3D visualization tools not only facilitates deeper comprehension -17 -but also promotes insightful discussions.Furthermore, the benefits of such a tool extend beyond the novice user.For seasoned practitioners, we have found this tool to significantly expedite the design process, enhancing time efficiency.Therefore, the implementation of this user-friendly, intuitive tool could revolutionize the methodological approaches in this field, streamlining processes, and fostering increased productivity and innovation.

Figure 1 .
Figure 1.IBSimu Interface of DemirciPRO: left panel contains design and simulation parameters, right top the design geometry and right bottom the simulation results.

Figure 2 .
Figure 2. DemirciPRO, Ion Source design, electrode selection.The shown DXF files are already included in the software.

Figure 3 .
Figure 3. IBSimu and DemirciPro comparison of the RMS radial beam envelope after ion extraction along the beam direction in cm.Note that the difference is with respect to standalone version of IBSimu and expressed in permille.

Figure 4 .
Figure 4. DemirciPro Low Energy Beam Transport (LEBT) design module.The design parameters are on the left, the transverse beam is shown at the top and the longitudinal beam behavior is shown at the bottom.The magnet and measurement station are represented by rectangles which are to scale in  axis but not in  direction.

Figure 5 .
Figure5.Upper(Lower) plot is the RMS beam radial envelope relative difference, RD, (%) between DemirciPRO and Travel (TraceWin) along the beam axis (cm).Note that the RD, with respect to Travel (TraceWin), is largest at the beam waist and is considerably smaller before and after.In Tracewin, the space charge effects are turned off by setting the beam current to 0 mA.

Figure 6 .
Figure 6.Parameters for geometric shape and numerical values for a solenoid magnet.

Figure 7 .
Figure 7. Solenoid magnetic field distribution (upper) through the direction of the beam ( = 0.42 cm) (lower) magnetic field distribution along  = 25.5 cm.In the upper graph, the red curve represents the magnetic field along the beam axis (Bz) and the green curve is for the radial direction (Br/r).However, in the lower one, Bz is shown in green and Br in red.The output from Fish.exe, a Windows program running over the WINE compatibility layer on a MacOS computer.

Figure 8 .
Figure 8.The skew quadrupole case, Left: geometric shape for parameters and numerical values, Right: the distributions of magnetic field components, green and red curves are for  and  components of the magnetic field.

Figure 9 .
Figure 9.A schematic representation of the pepper pot emittance measurement setup.

Figure 10 .
Figure 10.Pepper pot plate, simulation step output screen, the simulation parameters are on the left and the simulation results are on the right.

Figure 11 .
Figure 11.Pepper pot simulated measurement outputs, see text for details of the plots.

Table 1 .
DemirciPro and other similar design software.

Table 2 .
Input beam properties and designed LEBT Line properties.

Table 3 .
PPP emittance analysis results, the relative error is given with respect to the true value of 0.026 mm•mrad.