The field and particle trajectory simulator
Industry standard charged particle optics software
Refine your design: model > simulate > view > analyze > program > optimize it.
News: SIMION v8.1.3.4-TEST posted - EA with new GEM features! | ASMS 2017 posters
About | Documentation | Community/Support | Downloads | Ordering

SIMION 8.0 Issues/Bugs/Enhancements

Filter issues by query:
Issue I429 [80,enhancement,med-high,resolved]
  Define behavior of adj_elect[i] and adj_electXX for non-existent
  electrode numbers and #adj_elect.

  == SUMMARY ==
  The behavior of the `adj_elect` variable in user programs is
  currently as follows.

  `#adj_elect` returns the last adjustable electrode
  number in the current PA (as of 8.0.6-TEST11).  For example,
  if your PA0 has electrodes numbered 1, 2, 3, and 10,
  then `#adj_elect == 10`.  If your PA0 only has fast scalable electrodes
  (i.e. adjustable potential #0), then `#adj_elect == 0`.  `#adj_elect`
  is not accessible for arrays with no adjustable potentials
  (e.g. `fast_adjust` segment is not called).

  `adj_elect[i]` returns `nil` if `i` is a non-existant
  electrode (as of 8.0.5-TEST2).  Writing to `adj_elect[i]`
  for non-existant electrode `i` raises an error.  If your user
  program is not sure whether an electrode exists and is able
  to be written to, it may use code like this:

    if adj_elect[20] then adj_elect[20] = 10 end
  To iterate through all electrodes, you can do this:
    for i=0, #adj_elect do
      if adj_elect[i] then
        print(i, adj_elect[i])

  `adj_pole` is a synonym of `adj_elect`.

  This is also supported in PRG code (as of 8.0.5-TEST26).  PRG behavior
  is as follows.  `0 arcl adj_elect` is supported.  Storing to a non-existant
  electrode results in an error.  Skipped electrodes are allowed (Issue I414).
  Reading from a non-existant electrode always returns 0 (not `nil` since
  PRG doesn't support the concept of `nil`).

  == CHANGES ==

  As of 8.0.6-TEST11, `#adj_elect` in user programs now returns
  the maximum electrode number in the current array.  Previously it returned
  the number of contiguous electrodes starting at #1, which wasn't
  as useful.  This only affects arrays with skipped electrodes.
  As of 8.0.5-TEST2, `adj_elect[i]` returns `nil` if `i`
  is a non-existant electrode.  Writing to `adj_elect[i]`
  for non-existant electrode `i` raises an error.

  In 8.0.5-TEST2 - 8.0.6-TEST9, `#adj_elect` returned the number of
  adjustable electrodes having consecutive numbers starting at 1.
  Electrode 0 or electrodes following skipped numbers were not counted.
  This followed Lua conventions for tables but was not always useful.

  Prior to 8.0.5-TEST2, the behavior of #adj_elect and
  adj_elect[n] for undefined electrode n was undefined.  However, in
  practice, reading or writing to a non-existance electrode raised an error
  (except in cases of skipped electrodes (Issue I414), where no error
  was generated).  Here is a workaround that can be used in versions
  prior to 8.0.5-TEST2 for detecting electrodes:
    -- Returns true/false whether electrode # n exists in active PA.
    local function exists_electrode(n)
      return (pcall(function() return adj_elect[n] end))
    --Note also: adj_elect[0] returns electrode 0 even if not exist.
    --adj_elect[0] = 0 may crash if electrode 0 not exist

  Request based on tbraun-20070810/200801

  Implemented in 8.0.5-TEST2 through 8.0.6-TEST11.

Any comments on this web page? (will be sent to SIS SIMION Support)
[Optional] Your name: email: phone/fax: