Migrating to 2.0¶
pyRat 2.0 changes a few things that scripts written for 1.x
rely on. The full list is in pyRat’s CHANGELOG.md.
Logging¶
pyrat.log is now the standard logging module, kept
minimal (see Module pyrat):
pyrat.log.config()is gone:pyrat.log.enable(level)shows pyRat’s messages,pyrat.log.get(name)gives a script its own logger.The
HINTandRESULTlevels, the colour formatter and thelogs/file are gone.import pyratno longer configures logging.
# pyRat 1.x
plg = pyrat.log.config(__file__)
# pyRat 2.0
plg = pyrat.log.get("my_script")
pyrat.log.enable()
Vector-shaped fields are flat lists¶
Fields shaped as vectors (1 x N or N x 1) come back as flat
lists. A frame with several sections used to give
[[R0, R1, ...]] but [R0] with one section;
frame.get_coords() is now always [R0, R1, ...].
Code that unwrapped the outer list drops that step. Fields with both
dimensions above 1, and 3D fields, keep their nesting.
CrossPoint is a round wire¶
CrossPoint(nc, tc, radius) replaces
CrossPoint(nc, tc, thickness, width), and the radius
property replaces thickness and width. To keep the
same conductor area, current density and field:
# pyRat 1.x
cross = rat.mdl.CrossPoint(nc, tc, t, w)
# pyRat 2.0
cross = rat.mdl.CrossPoint(nc, tc, rat.mdl.CrossPoint.radius_from_area(t * w))
Coil source settings¶
These follow the Rat-Models libraries pyRat 2.0 builds against:
SourceType.AUTOtakes fixed source settings: a coil’sline_source_points,softness,wire_core,centerline_radiusandsoleno_num_layersno longer reach anAUTOcoil. Code that raised them on anAUTOcoil for finer sources selects an explicit type, e.g.SourceType.LINE_CURRENTS.num_gaussis the integration order only: the line currents of a coil takeline_source_points. A script that setnum_gaussto refine its sources setsline_source_pointstoo (a saved model converts on load).softnessreplacessofteningas the soft core radius factor, without its extrasqrt(2).softeningstays, with its former meaning, so existing scripts keep theirs.
Smaller changes¶
Errors raised by RAT are
pyrat.rat.RatError(aRuntimeError), Armadillo errorsValueErrororIndexError; reading a write-only property raisesAttributeError.Matrices come back Fortran-ordered (column-major, as in Armadillo), which only shows in
.flagsand.strides.calculate()defaultstimeto0.0.Mlfmm.create(targets, sources): the keyword names now match their arguments (srcused to name the targets); check calls that pass them by keyword.