simion.pas¶
SYNOPSIS¶
-- load array and examine all points.
local pa = simion.pas:open(
'c:/Program Files/SIMION-8.1/examples/quad/quad.pa#')
pa:save'quad.pa#' -- save locally to a folder we have write permission to
for zi=0,pa.nz-1 do
for yi=0,pa.ny-1 do
for xi=0,pa.nx-1 do
local potential, is_electrode = pa:point(xi,yi,zi)
print(potential, is_electrode)
end end end
-- modify it
pa:point(38,0,0, 3,true) -- x,y,z, potential,is_electrode
-- refine it
pa:refine()
-- fast adjust it
pa:fast_adjust{[3] = 100}
-- pa:close() -- optionally close it
DESCRIPTION¶
Compatibility Warning: The features in this module are only available in the SIMION 8.1.0 and above.
This module enables programmatic access and manipulation of SIMION potential arrays (PA’s). This includes creating, reading, manipulating, and refining PAs from Lua. The arrays are loaded into the memory of the SIMION process (in contrast to the earlier SL Libraries).
The list of existing arrays in memory can be accessed from the simion.pas array. For example, to print the names of all open arrays, execute this from the SIMION command bar:
for i=1,#simion.pas do print(i, simion.pas[i].filename) end
New arrays can be loaded from a file:
pa1 = simion.pas:open('quad.pa#')
or a blank array can be created in memory:
pa2 = simion.pas:open()
pa2.symmetry = '2dplanar'
pa2:size(100,100,100)
A common application is to iterate over all points to read or modify them:
-- Create a spherical electrode in the PA.
for zi=0,pa2.nz-1 do
for yi=0,pa2.ny-1 do
for xi=0,pa2.nx-1 do
if xi^2 + yi^2 + zi^2 < 50^2 then
pa2:point(xi,yi,zi, 1,true) -- 1V,electrode
end
end end end
Some functions differ only in the coordinates used:
potential = pa:potential(1,3,5)
potential = pa:potential_vc(1.1,-3.2,5.9)
The first type takes non-negative integer coordinates. These represent grid points in the original array (as seen in Modify) before application of symmetry, mirroring, and interpolation between grid points.
The second type takes real number coordinates. These are also in units of grid units but represent physical coordinates (as seen in View) after application of symmetry, mirroring, and interpolation between grid points.
Further functionality is described in the below API.
Note
See these additional sections in this topic in the offline SIMION 8.1.0 help file:- INTERFACE
See Also¶
To locate the PA object for PA instance number n on a workbench, use simion.wb.instances[n].pa. See simion.wb.
Compatibility¶
In 8.1.0-TEST13, x_mm_per_gu/y_mm_per_gu/z_mm_per_gu was renamed to dx_mm/dy_mm/dz_mm.
8.1.0.16-TEST - pa:save now raises on error. Renamed pa:rescale to pa:resample. Also corrected documentation on some error handling behaviors.
- 8.1.0.19 - pa.filename may now be nil (in get or set)
- if the array in memory is not to be associated with a file on disk.
8.1.0.19 - Added pa.saved and pa.refined properties.
8.1.0.19 - pa:clear now resets max_voltage to default 100000.
8.1.0.40 - Added pa.refinable.
8.1.0.43 - pa:size(nx,ny,nz) no longers clears array if size unchanged.
