radiasoft / rswarp

Python utilities specific to running Warp
Other
5 stars 5 forks source link

Track electrons through argon with space charge at different pressures? #4

Open robnagler opened 6 years ago

robnagler commented 6 years ago

A user writes:

I would like to use the software rswarp for the following issue: Simulating an electron beam (CW) of several keV and Ampere, which is tracked through an argon gas. Then analyzing the space charge compensation rate and potentials for different gas pressures (10^-8 to 10^-4 mbar). Would this be possible to simulate with rswarp and which libraries do I need?

cchall commented 6 years ago

This should be doable with Warp and optionally with rswarp to extend ionization capabilities.

The main reason to want to use rswarp to handle the ionization is to provide functional forms for the cross section and ionization product's energies and angular distribution. Warp currently only supports static values for these items and does not support any setting of a product's vector. If the user has some function for any of these items then rswarp could be of use.

bruhwiler commented 6 years ago

I think some of these rswarp capabilities have been recently merged into the Warp base code, although I'm not sure exactly what or when.

We should verify which version of Warp is being used.

bruhwiler commented 6 years ago

@cchall and I verified that the rswarp extensions for ionization physics have not yet been added to the Warp base code.

It seems that helping the user implies offering some advice or even providing a Warp Python script. @cchall will commit a beta quality example script to the repository and post the location here.

ohinrichs commented 6 years ago

@bruhwiler a sample script for my issue would of course be very helpful. I am new to warp/rswarp, but I already worked with TraceWin and G4Beamline.

ohinrichs commented 6 years ago

I have an additional question: With the ionization module I am able to produce the electron and ion pairs of the residual gas. But to get into an equilibrium state after some time the ions must leave the ion gas. The rate of loss will then depend upon the ion gas density at the wall and the average normal velocity component there. The density will be controlled by the Boltzmann law.

Is this effect considered in the code?

ohinrichs commented 6 years ago

1.1699548.pdf Here is a paper describing the processes I want to simulate.

bruhwiler commented 6 years ago

Hello @ohinrichs

Thanks for the interesting paper.

I think the ion macroparticles are created with zero velocity. We are planning to add the option for them to be created with a random velocity, based on the specified temperature of the neutral gas.

If you are interested to look in the code, then we can assist. RadiaSoft is in the process of hiring, and we may have someone who can begin working on this in 4 to 6 weeks.

For the system described in the paper, there may be complications if the gas temperature varies with position. If the gas temperature is uniform, and is equal to the wall temperature, then Warp should be able to model the problem, after the finite temperature ion capability is implemented.

ohinrichs commented 6 years ago

Oh I see. I thought giving the added macroparticles an emitted energy would also create a velocity. As a first try I would assume a uniform gas temperature equal to the wall temperature. So I am looking forward to the implementation.

cchall commented 6 years ago

@ohinrichs @bruhwiler There is now an example magnetized_cooler.py in examples/ionization/ as of 7bc5c3200ee010746134d51b7fa2664ada1cb002. This example comes from simulations of 3 MeV electrons ionizing H2 gas, but hopefully is a reasonable starting point. There is a corresponding IPython notebook in the same folder that briefly discusses some of the experiment that the simulation is based on, it also contains some possibly helpful examples of loading and plotting data. Please let me know if you encounter errors or have questions.

We do currently create the ions with zero initial velocity https://github.com/radiasoft/rswarp/blob/5b32d9f097ce2ba4c1b121aef8a506deba59d869/examples/ionization/magnetized_cooler.py#L178-L179

However, any callable function could be dropped in and used to set the ion velocities depending on what your model requires. If there is a varying ion temperature it should be possible to register multiple Ionization instances, each in a different volume. If the temperature does not change very rapidly this could be a reasonable solution. It shouldn't be too hard to implement a more elegant solution if necessary though.

cchall commented 6 years ago

An update on this issue, there is now builtin functionality, as of da49b9c6f170b1f7e5aafb1b5e840c9561252a4e, for creating ion products with a thermal velocity distribution. See the example magnetized_cooler.py for an example of adding this to a simulation.

ohinrichs commented 6 years ago

Thank you for the update! The simulation time is scaling strongly with the beam_current. So for the 15 A it takes a long time. Is there a way to accelerate/prevent that? Is it right that the emitted ions are destroyed when they reach the pipe wall as a result of the thermal movement?

cchall commented 6 years ago

@ohinrichs

The simulation time is scaling strongly with the beam_current.

You may be able to improve the time scaling by adjusting particle weights for the beam/ionization products. In magnetized_cooler.py the beam weight is set automatically by Warp based on the number of macroparticles injected eache step ptcl_per_step and the current beam.ibeam. The weight is directly set for the ionization products by the weight parameter: https://github.com/radiasoft/rswarp/blob/da49b9c6f170b1f7e5aafb1b5e840c9561252a4e/examples/ionization/magnetized_cooler.py#L149-L150 Once a species object is instantiated the weight may be adjusted by setting the sw attribute.

Is it right that the emitted ions are destroyed when they reach the pipe wall as a result of the thermal movement?

This is the intended behavior for the magnetized_cooler example. If you would like to set reflection this can be done by changing the pbound attributes in top from absorb to reflect: https://github.com/radiasoft/rswarp/blob/da49b9c6f170b1f7e5aafb1b5e840c9561252a4e/examples/ionization/magnetized_cooler.py#L78-L80 Note that wp.top.pboundxy is not explicitly set here but it can also be set to reflect. The second step if you want reflection is to no longer set any conductors to be scrapers. Comment out or remove appropriate conductors from the list in: https://github.com/radiasoft/rswarp/blob/da49b9c6f170b1f7e5aafb1b5e840c9561252a4e/examples/ionization/magnetized_cooler.py#L268-L269 Conductors that are not scrapers will still be used appropriate in the field solve but particles will pass through them.

Hope this helps!