Skip to content

A helpful tool to help with creating SIMION .gem files

License

Notifications You must be signed in to change notification settings

j-medland/simion-gem-builder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SIMION .gem File Builder

SIMION 8.0 can make use external .gem files to define the geometry for Potential Arrays. The syntax is reasonably straight forward but does not lend itself to easy programmatic generation.

This tool aims to make creating .gem syntax more akin to modifying a HTML DOM.

Installation

npm install --save simion-gem-builder

The Basics

The following

// require
const gem = require('simion-gem-builder')
// create a new geometry document
const geometry = gem.geometry()
// add pa_define, include and comment statements
geometry.paDefine(101,101,1,'planar','None','electrostatic', 1)
  .include('some-file')
  .comment('some comment')
// add an electrode at location 20,20,20
const e1 = geometry.append(gem.locate(20,20,20))
                   .append(gem.electrode(1))
// add a nested electrode
e1.append(gem.electrode(2))
// render the document
console.log(geometry.render())

yields the output

pa_define(101,101,1,planar,None,electrostatic,1)
include(some-file)
; some comment
electrode(1)
{
   electrode(2)
}

API Notes

Methods can generally be chained but care should be taken with the .append() method which returns the child element that was appended instead of the parent element.

The .render() method returns a String which is pretty formatted by default. The spacing can be reduced by specifying the padding character using .render('').

What about all the other elements?

Any other element can be added using

const anything = geometry.append('anything'[,arg1 [,arg2 [,argN])

where the first argument of the constructor is the instruction syntax and any subsequent arguments will appear in brackets after the instruction.

This is a shorthand for

const anything = geometry.append(new gem.element('anything'[,arg1 [,arg2 [,argN]))

It is hoped that with future development, more elements can be added to simplify the usage of the library.

About

A helpful tool to help with creating SIMION .gem files

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published