Section 2.7 of the User's Guide for CPO2D and CPO3D

(or proceed to section 2.8)


Magnetic fields.


Before Dec 2012 magnetic fields could be added only in CPO3D and CPO3DS, and the information below refers only to 3D.

For magnetic fields in CPO2D and CPO2DS, see magnetic fields in 2D.


See also the note on specification of magnetic fields..


The magnetic field can be synthesised by adding together components selected from a menu, or a user-defined field can be called. The maximum number of selections from the menu is maxvolts, which is usually at least 75.


All the items in the menu have the strength and direction specified by the user.


The available field components are:

Uniform magnetic field

Circular current hoop

Solenoid, type 1, stack of hoops

Solenoid, type 2, helix divided into straight sections

‘Coiled’ solenoid (type 1)

Straight finite length of current

Point dipole

Circular arc of current

In-built program for interpolating from a pre-calculated 3D grid of field values

In-built program for interpolating from a pre-calculated 2D grid of field values, for an axially symmetric magnetic field

User -defined program (supplied with package) for interpolating from a pre-calculated 3D grid of field values

User-defined field

See also:

Using CPO2D or 3D to calculate a magnetic field by solving Laplace’s equation (that is, converting an electric field to a magnetic field)

Note on scaling total field.

Note on specification of magnetic fields..


Program-supplied fields (the first 6 in the above list):

If the program is asked to evaluate the field at a point that is on or very near a hoop, solenoid or straight length, it will return a limited, high value, but if the point is too near a point dipole the program will stop (with an error message). High values can be excluded from the vector plots.


In-built programs for interpolating from pre-calculated 2D or 3D grid of field values:

The user specifies the name of a file that holds pre-calculated field values at a grid of points. The required format of the file is given in 3D note on specification of fields.


User -defined program for interpolating from a pre-calculated 3D grid of field values:

A routine for doing this is supplied with the program. It is called ‘user3d.cpp’, is listed in 3D note on user-supplied field and can be copied from Appendix 4 at the end of file cpo3d.dat (which is supplied with the CPO package). A compiled version of it, called ‘user3d.dll’ is supplied with the package. The magnetic field components are interpolated from a grid of values that have been pre-calculated by the user and are held in the file grid.dat.


User-defined field:

The procedure for incorporating a user-supplied routine is explained in 3D note on specification of fields.

With a user-defined field the program requires that a differentiation length and a tolerance level be specified. These are used by the program to test the values of div and curl (that is, rot) of the field, which must be zero for a physically possible field. The tests will be used every time the field is called, unless the tolerance level is greater than 1, in which case the field is never tested. The differentiation length is used for numerical differentiation of the field to calculate div and curl.. The tolerance level is the maximum value of the ratio div/(magnitude of field) or curl/(magnitude of field) that will be tolerated.