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
This page is abridged from the full SIMION "Supplemental Documentation" (Help file). The following additional sections can be found in the full version of this page accessible via the "Help > Supplemental Documentation" menu in SIMION 8.1.1 or above:INTERFACE
Examples¶
** Mirror contents of first PA in memory (reverse in X direction).**
pa = simion.pas[1]
for x=0,math.floor((pa.nx-1)/2) do
for y=0,pa.ny-1 do
for z=0,pa.nz-1 do
local xr = pa.nx-1-x
local v1,e1 = pa:point(x,y,z)
local v2,e2 = pa:point(xr,y,z)
-- swap points
pa:point(x ,y,z, v2,e2)
pa:point(xr,y,z, v1,e1)
end end end
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¶
8.2EA-20150727(8.1.2.24) - New
pa:flood_fill
.8.2EA-20141211(8.1.2.21) - New
simion.pas pa:refine()
disk
option added to support in-RAM refines of PA# arrays.8.2EA-20140411(8.1.2.8) - Fix
simion.pas pa:binary_import()
added.8.1.2.6 - Fix
simion.pas pa.symmetry
broken in 8.1.2.4.8.1.1.30 - Fix
simion.pas pa:crop()
may crash on some PA sizes.8.1.1.23 -
simion.pas pa:crop()
wasn’t properly guarding against attempts to crop a region larger than the original PA.8.1.1.22 -
simion.pas pa:crop()
now saves electrode solution arrays on disk as well (newpersist
argument).8.1.1.22 -
simion.pas pa:crop()
now properly preserves surface enhancement information.8.1.1.18 - Add
simion.pas pa.path
. Writing tosimion.pas pa.filename
andsimion.pas pa.path
now behave identically, andsimion.pas pa.filename
now never returns relative path info.8.1.1.16 -
pa:refine
withsolutions
parameter now gives error if .pa# style array not used.8.1.1.14 - Fix
simion.pas tostring(pa)
rendering of magnetic scaling factor.8.1.1.11 - Added
simion.pas pa:surface_info()
andsimion.pas pa:fill()
.simion.pas pa:clear()
now clears enhanced surface information too.8.1.0.43 -
pa:size(nx,ny,nz)
no longers clears array if size unchanged.8.1.0.40 - Added
pa.refinable
.8.1.0.19 - pa:clear now resets max_voltage to default 100000.
8.1.0.19 - Added pa.saved and pa.refined properties.
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.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-TEST13 - x_mm_per_gu/y_mm_per_gu/z_mm_per_gu was renamed to dx_mm/dy_mm/dz_mm.