Refine

The SIMION “Refine” function is what calculates fields in a Potential Array by solving the Laplace Equation (or Poisson Equation).

See Chapter 6 “Refining and Fast Adjusting Potential Arrays” in the SIMION User Manual for details.

Enhancements

SIMION refining capabilities have been improved over time. More significant improvements (changes) include

  • EA-20141211 - RAM-only PA# Refining. Fast adjust (PA#) style arrays can now be refined entirely in RAM, without writing electrode solution arrays (.pa0, .pa1, etc. files) to disk.
  • 8.2EA-20120430 - Magnetic permeability and magnetic (vector) potential support in Refine.
  • 8.1.1 - Electrode Surface Enhancement / Fractional Grid Units - Improves field calculation accuracy by about an order of magnitude when electrode surfaces don’t perfectly align to grid units, which includes curved surfaces. The surface is saved as .pa-surf files.
  • 8.1.1 - Nested refine supported in some ways via Lua, where to arrays are refined together in a coupled way, transfering pointe between boundaries. See Field Emission.
  • 8.1.1 - Dielectric materials now supported in Refine (isotropic dielectrics).
  • 8.1.0 - Anisotropically Scaled Grid Cells in SIMION - allows rectangular (non-square) grid cells. The grid cell size (mm per grid unit, mm/gu) is allowed to be different in the three x, y, and z dimensions.
  • 8.1.0 - 64-bit array sizes. PA’s can now be larger than 2 GB of RAM. See also RAM and Memory.
  • 8.1.0 - Multi-core CPU support in Refine. This improves Refine speed by using multiple CPU cores (multiple threads) during Refine.
  • 8.1.0 - Poisson Solver in SIMION - Refine now supports solving the Poisson Equation.
  • 8.1.0 - Option to refine only a single PA# electrode solution array at a time. Usage: pa:refine{solutions={2}}. Useful for splitting a Refine across multiple machines. See Issue-I503 and pa:refine. This is an alternative to the multithreaded Refine capabilities (Multicore CPU support).
  • 8.1.0 - Lua API to Refine (pa:refine): New function for invoking Refine on PA object in RAM from Lua.
  • 8.1.0(8.1EA-20101216) - Neumann boundary conditions on open PA edges without mirroring defined now treated slightly more properly.
  • 8.0.4 - Resuming of terminated PA# refines. Any completed electrode solution arrays on disk from a previous Refine attempt can be reused. Issue-I413.
  • 8.0.3 - Additional Fast Proportional Scaling Solutions - Allows multiple electrodes to share the same electrode solution array file, to conserve memory, when their voltages are always linearly dependent, like in resistor chains. Uses .pa+ files.
  • 8.0.2 - Optional automatic Refine of PA’s on IOB loading. Issue-I341. Further improved in 8.1.0.40/8.1.1.29 (create from GEM).
  • 8.0.0 - New refine Command Line Interface option, for invoking Refine from batch mode or a command-line.

A number of these are highlighed in SIMION Advances.

Some other related enhancements include

  • Cropping a PA after refining it, reduces RAM usage during a Fly’m if some volume in the array is required to properly Refine the array but is no longer needed during the Fly’m because particles don’t fly in that region.
  • Effectively Programmatically Controlling PA Instance Priority, helps if two PA’s are refined independently and overlap but the fields are not accurate on the edges and these regions should be hidden from particles. This approach may be more convenient than Crop.

RAM-only PA# Refine

In 8.2EA-20141211, PA# arrays can now be refined entirely in RAM, without writing electrode solution arrays (.pa0, .pa1, etc.) to disk.

This approach avoids writing to disk, but it can consume much more RAM during Refine since all the electrode solution arrays are in RAM at the same time (rather than a single array in RAM).

Here’s how to Fly and IOB from the command-line:

simion.exe --nogui --noprompt fly --disk=0 --refine-convergence=5e-7 quad.iob

or from Lua:

simion.command('fly --disk=0 --refine-convergence=5e-7 quad.iob')

Any PA0 files that don’t exist will be created and refined entirely in RAM. Any PA0 files that are on disk, will be loaded from disk though. See also fly –disk=d for details.

Below is some example Lua code to do the refining yourself, which is more verbose but provides more flexibility:

-- First create and Refine the PA0 arrays in RAM.
pa = simion.open_gem('quad.gem'):to_pa()
pa.filename = 'quad.pa#'
--pa = simion.pas:open('quad.pa#')
pa:refine{convergence=5e-7, disk=false}
--
pa = simion.open_gem('quadin.gem'):to_pa()
pa.filename = 'quadin.pa#'
--pa = simion.pas:open('quadin.pa#')
pa:refine{convergence=5e-7, disk=false}
--
pa = simion.open_gem('quadout.gem'):to_pa()
pa.filename = 'quadout.pa#'
--pa = simion.pas:open('quadout.pa#')
pa:refine{convergence=5e-7, disk=false}

-- just some tests
print(pa.path)
print(pa:potential_vc(10,10,0, {[1]=100,[2]=-100}))

-- Load IOB and Fly'm.
simion.command 'fly --remove-pas=0 quad.iob'

Even if a PA# array is never written to disk, it is still necessary to assign it a file name with a .pa# extension in order for SIMION to recognize it as a fast adjustable array (not basic .PA style array). That is what the pa.filename = 'quad.pa#' does above.

If you use the simion.command 'fly ...' command to initiate a Fly’m from Lua (rather than the GUI), you probably will want the --remove-pas=0 option to prevent removing all PA’s from RAM before and after the Fly’m (or --remove-pas=2 to remove them only at the end (2) of the Fly’m). See also fly –remove-pas=d for details.

Normally, if a fast_adjust or init_p_values segment in a workbench user program doesn’t touch a fast adjustable electrode in a PA, then the corresponding solution array will be unloaded from RAM. However, this unloading is not done for a RAM-only refined .PA0 array because the solutions arrays are not on disk and so would be lost, but we may still need them in a future rerun.

Some forms of fast adjusting (e.g. the Fast Adjust button or the simion.pas pa:fast_adjust() function) normally fast adjust by reading solutions arrays from disk but not keeping them in RAM. However, for a RAM-only refined .PA0 array, these solution arrays are already in RAM, so the RAM copies are used instead.

Limitations and possible improvements:

  • Presently pa:save() doesn’t save to disk the electrode solution arrays from a RAM-only refine.
  • Presently RAM-only PA# refines can only be initiated from Lua, not from the GUI.
  • IOB loading from command-line or simion.command presently writes to disk if needing to Refine.
  • .pa+ arrays not yet tested
  • fly --disk=0 still writes any auto-created GEM files to disk.
  • wb:load doesn’t currently accept parameters, including disk.