simionx.MField - Biot-Savart magetic field calculations¶
SYNOPSIS¶
-- mag.lua (assumes workbench is similarly named mag.iob)
-- Example SIMION workbench program applying calculated
-- solenoid magnetic field.
simion.workbench_program()
local MField = require "simionx.MField" -- load module
-- Define solenoid magnetic field.
local field = MField.solenoid_hoops {
first = MField.vector(-10,0,0),
last = MField.vector(-10,0,0)
radius = 1.2,
nturns = 200
}
-- Draw wires in SIMION 8.1
field:draw()
-- SIMION mfield_adjust segment overrides
-- magnetic fields in magnetic PA at current
-- particle position.
function segment.mfield_adjust()
-- Calculate solenoid magnetic field at current
-- particle position (with Biot-Savart calculation).
ion_bfieldx_gu, ion_bfieldy_gu, ion_bfieldz_gu
= field(ion_px_mm, ion_py_mm, ion_pz_mm)
end
DESCRIPTION¶
This module calculates various magnetic fields from wire currents using the Biot-Savart Law. The magnetic fields calculated can be used directly or, as often done, applied in a workbench via an mfield_adjust user program segment.
The module is loaded with
local MField = require "simionx.MField"
This module is typically used by first constructing an object defining the wire current configuration:
local field = MField.line_segment {
current = 2,
first = MField.vector(-50,0,0),
last = MField.vector(50,0,0)
}
This defines an infinitely thin line segment of wire with 2 amps going from point (x,y,z) = (-50,0,0) to point (x,y,z) = (50,0,0) mm. It does not yet calculate the magnetic field though.
To calculate the magnetic field at some arbitrary point from this magnetic system, we call the object as a function, passing it the x, y, and z components of the observation point:
local bx, by, bz = field(0,0,1)
print(bx,by,bz) --> 0 -3.99920023992 0
In SIMION 8.1.0, wires from the field object can be drawn on the View screen with the draw method:
field:draw()
The above does nothing in previous SIMION versions, but you can test whether it will do anything by checking the MField.can_draw boolean variable.
Note
See these additional sections in this topic in the offline SIMION 8.1.0 help file:- INTERFACE
Changes¶
20110826 - Added mfield:draw method to draw wires on the SIMION View screen in SIMION 8.1.0.
SOURCE¶
(c) 2007-2011 Scientific Instrument Services, Inc. Licensed under the terms of SIMION 8.0/8.1. www.simion.com. D.Manura-200704.
version: 20110826
