dipoleq
DipolEq: Levitated Dipole Equilibrium Solver
DipolEq is a Python package for solving the equilibrium of a levitated dipole magnetized plasma. It is a Python wrapper around the C code that was originally written by Michael Mauel and his group at Columbia University in the early 1990s called TokaMac. The C code was later modified by Darren Garnier at Columbia for use in the LDX experiment. The Python wrapper was written by Darren Garnier at OpenStar Technologies, LTD.
- class dipoleq.Machine
Bases:
MachineMachine class for the Dipole Equilibrium Solver Child of core.Machine
- property Coils
Array of COILS
- property Confidence
(self) -> float
- property Iname
Input name
- property Info
Info about the machine
- property IterFixed
(self) -> int
- property IterFree
(self) -> int
- property LHGreenStatus
(self) -> int
- property LHname
LH name
- property Limiters
Get the limiters
- property MGname
MG name
- property MGreenStatus
(self) -> int
- property MaxIterFixed
(self) -> int
- property MaxIterFree
(self) -> int
- property MaxIterMCarlo
(self) -> int
- property Measures
Get the measurements
- property Name
Set the name
- property NumCoils
Number of coils, setting will erase old coils
- property NumEqualEq
(self) -> int
- property NumLimiters
Number of limiters, setting will erase old limiters
- property NumMCarloData
(self) -> int
- property NumMCarloEq
(self) -> int
- property NumMeasures
Number of measurements, setting will erase old measurements
- property NumSeps
Number of separatrixes, setting will erase old separatrixes
- property NumShells
Number of shells, setting will erase old shells
- property Oname
Output name
- property Plasma
The Plasma object
- property PsiGrid
The PsiGrid object
- property RSname
RS name
- property RestartStatus
(self) -> int
- property RestartUnkns
(self) -> int
- property SGname
SG name
- property SGreenStatus
(self) -> int
- property SInductStatus
(self) -> int
- property SMname
SM name
- property Seps
Get the separatrixes
- property Shells
Get the shells
- property Start
(self) -> str
- property Stop
(self) -> str
- property VacuumOnly
(self) -> int
- add_coil_J
Add Coil currents
- add_shell_J
Add Shell currents
- diff(other, verbose=False)
display the differences between two machines
- find_J
Find J
- find_plasma_boundary
Find plasma boundary
- find_shell_current
Find shell current
- free_bndry_greens
Free boundary greens
- free_meas_greens
Free measurement greens
- classmethod from_dict(input_data)
Generate a Machine object from a dictionary
- classmethod from_file(filename)
Generate a Machine object from a file
- classmethod from_fileinput(filename)
Generate a Machine object from a .in file Using the Python code to read the file
- classmethod from_input_data(valid_input)
Generate a Machine object from a pydantic verified MachineIn object
- classmethod from_yaml(filename)
Generate a Machine object from a .yaml file
- get_inner_limiter_contact_point()
Get the inner limiter contact point
- get_outer_limiter_contact_point()
Get the outer limiter contact point
- get_plasma_parameters
Get plasma parameters
- init
Initialize Machine
- least_squares
Least squares
- load_bndry_greens
Load boundary greens
- load_meas_greens
Load measurement greens
- psi_boundary
Calculate psi boundary
- read_restart
Read the restart file
- set_NumSubShells
Reallocate sub-shells for Shells[i]
- set_NumSubcoils
- set_coil_NumSubCoils
Replace coil[i] with a new Coil having n sub-coils
- set_start_time
Set the start time
- set_stop_time
Set the end time
- solve(quiet=True)
Solve the equilibrium based on the current machine data
- to_geqdsk(filename, NormalizeAtAxis=False)
Save the machine data to a g-eqdsk file
- to_hdf5(filename)
Save the machine data to an HDF5 file
- write_GS2_geo
Write GS2 geometry file
- write_restart
Write the restart file
- zero_J
Zero J
- pydantic model dipoleq.MachineIn
Bases:
BaseModel- Parameters:
data (
Any)
Show JSON schema
{ "title": "MachineIn", "type": "object", "properties": { "MaxIterFixed": { "anyOf": [ { "type": "integer" }, { "type": "null" } ], "default": 0, "title": "Maxiterfixed" }, "MaxIterFree": { "anyOf": [ { "type": "integer" }, { "type": "null" } ], "default": 50, "title": "Maxiterfree" }, "Name": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": "pyDipolEQ", "title": "Name" }, "Info": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": "DipolEQ Equilibrium", "title": "Info" }, "Oname": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Oname" }, "Iname": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Iname" }, "MGname": { "default": "", "title": "Mgname", "type": "string" }, "LHname": { "default": "", "title": "Lhname", "type": "string" }, "RSname": { "default": "", "title": "Rsname", "type": "string" }, "RestartStatus": { "anyOf": [ { "type": "boolean" }, { "type": "null" } ], "default": false, "title": "Restartstatus" }, "RestartUnkns": { "anyOf": [ { "type": "boolean" }, { "type": "null" } ], "default": false, "title": "Restartunkns" }, "LHGreenStatus": { "anyOf": [ { "type": "boolean" }, { "type": "null" } ], "default": false, "title": "Lhgreenstatus" }, "MGreenStatus": { "anyOf": [ { "type": "boolean" }, { "type": "null" } ], "default": false, "title": "Mgreenstatus" }, "NumEqualEq": { "anyOf": [ { "type": "integer" }, { "type": "null" } ], "default": 0, "title": "Numequaleq" }, "VacuumOnly": { "anyOf": [ { "type": "boolean" }, { "type": "null" } ], "default": false, "title": "Vacuumonly" }, "FitMeasurements": { "anyOf": [ { "type": "boolean" }, { "type": "null" } ], "default": false, "title": "Fitmeasurements" }, "PsiGrid": { "$ref": "#/$defs/PsiGridIn" }, "Plasma": { "$ref": "#/$defs/PlasmaIn" }, "Coils": { "items": { "$ref": "#/$defs/CoilIn" }, "title": "Coils", "type": "array" }, "Limiters": { "items": { "$ref": "#/$defs/LimiterIn" }, "title": "Limiters", "type": "array" }, "Separatrices": { "anyOf": [ { "items": { "$ref": "#/$defs/SeparatrixIn" }, "type": "array" }, { "type": "null" } ], "default": null, "title": "Separatrices" }, "Measures": { "anyOf": [ { "items": { "$ref": "#/$defs/MeasureIn" }, "type": "array" }, { "type": "null" } ], "default": null, "title": "Measures" }, "Shells": { "anyOf": [ { "items": { "$ref": "#/$defs/ShellIn" }, "type": "array" }, { "type": "null" } ], "default": null, "title": "Shells" }, "NumCoils": { "anyOf": [ { "type": "integer" }, { "type": "null" } ], "default": null, "title": "Numcoils" }, "NumShells": { "anyOf": [ { "type": "integer" }, { "type": "null" } ], "default": null, "title": "Numshells" }, "NumLimiters": { "anyOf": [ { "type": "integer" }, { "type": "null" } ], "default": null, "title": "Numlimiters" }, "NumSeps": { "anyOf": [ { "type": "integer" }, { "type": "null" } ], "default": null, "title": "Numseps" }, "NumMeasures": { "anyOf": [ { "type": "integer" }, { "type": "null" } ], "default": null, "title": "Nummeasures" } }, "$defs": { "CDipoleIntStableIn": { "properties": { "Type": { "anyOf": [ { "const": 6, "type": "integer" }, { "const": "DipoleIntStable", "type": "string" }, { "const": "6", "type": "string" } ], "title": "Type" }, "RPeak": { "anyOf": [ { "type": "number" }, { "type": "null" } ], "title": "Rpeak" }, "ZPeak": { "anyOf": [ { "type": "number" }, { "type": "null" } ], "title": "Zpeak" }, "PEdge": { "anyOf": [ { "type": "number" }, { "type": "null" } ], "title": "Pedge" }, "PsiFlat": { "anyOf": [ { "type": "number" }, { "type": "null" } ], "title": "Psiflat" }, "NSurf": { "anyOf": [ { "type": "integer" }, { "type": "null" } ], "title": "Nsurf" }, "fCrit": { "anyOf": [ { "type": "number" }, { "type": "null" } ], "title": "Fcrit" } }, "required": [ "Type", "RPeak", "ZPeak", "PEdge", "PsiFlat", "NSurf", "fCrit" ], "title": "CDipoleIntStableIn", "type": "object" }, "CDipoleStablePsiNIn": { "properties": { "Type": { "anyOf": [ { "const": 7, "type": "integer" }, { "const": "DipoleStablePsiN", "type": "string" }, { "const": "7", "type": "string" } ], "title": "Type" }, "PsiNPeak": { "anyOf": [ { "type": "number" }, { "type": "null" } ], "title": "Psinpeak" }, "PEdge": { "anyOf": [ { "type": "number" }, { "type": "null" } ], "title": "Pedge" }, "PsiFlat": { "anyOf": [ { "type": "number" }, { "type": "null" } ], "title": "Psiflat" }, "NSurf": { "anyOf": [ { "type": "integer" }, { "type": "null" } ], "title": "Nsurf" }, "fCrit": { "anyOf": [ { "type": "number" }, { "type": "null" } ], "title": "Fcrit" } }, "required": [ "Type", "PsiNPeak", "PEdge", "PsiFlat", "NSurf", "fCrit" ], "title": "CDipoleStablePsiNIn", "type": "object" }, "CDipoleStdIn": { "properties": { "Type": { "anyOf": [ { "const": 5, "type": "integer" }, { "const": "DipoleStd", "type": "string" }, { "const": "5", "type": "string" } ], "title": "Type" }, "RPeak": { "anyOf": [ { "type": "number" }, { "type": "null" } ], "title": "Rpeak" }, "ZPeak": { "anyOf": [ { "type": "number" }, { "type": "null" } ], "title": "Zpeak" }, "PsiPeak": { "anyOf": [ { "type": "number" }, { "type": "null" } ], "title": "Psipeak" }, "PsiEdge": { "anyOf": [ { "type": "number" }, { "type": "null" } ], "title": "Psiedge" }, "PsiDipole": { "anyOf": [ { "type": "number" }, { "type": "null" } ], "title": "Psidipole" }, "PPeak": { "anyOf": [ { "type": "number" }, { "type": "null" } ], "title": "Ppeak" }, "PrExp": { "anyOf": [ { "type": "number" }, { "type": "null" } ], "title": "Prexp" } }, "required": [ "Type", "RPeak", "ZPeak", "PsiPeak", "PsiEdge", "PsiDipole", "PPeak", "PrExp" ], "title": "CDipoleStdIn", "type": "object" }, "CoilIn": { "description": "Coil input data.", "properties": { "Name": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Name" }, "Enabled": { "anyOf": [ { "type": "boolean" }, { "type": "null" } ], "default": true, "title": "Enabled" }, "InitialCurrent": { "title": "Initialcurrent", "type": "number" }, "R": { "anyOf": [ { "type": "number" }, { "type": "null" } ], "default": null, "title": "R" }, "dR": { "anyOf": [ { "type": "number" }, { "type": "null" } ], "default": null, "title": "Dr" }, "Z": { "anyOf": [ { "type": "number" }, { "type": "null" } ], "default": null, "title": "Z" }, "dZ": { "anyOf": [ { "type": "number" }, { "type": "null" } ], "default": null, "title": "Dz" }, "NumSubCoils": { "anyOf": [ { "type": "integer" }, { "type": "null" } ], "default": null, "title": "Numsubcoils" }, "SubCoils": { "anyOf": [ { "items": { "$ref": "#/$defs/SubCoilIn" }, "type": "array" }, { "type": "null" } ], "default": null, "title": "Subcoils" } }, "required": [ "InitialCurrent" ], "title": "CoilIn", "type": "object" }, "LimiterIn": { "properties": { "Name": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "title": "Name" }, "R1": { "title": "R1", "type": "number" }, "Z1": { "title": "Z1", "type": "number" }, "R2": { "title": "R2", "type": "number" }, "Z2": { "title": "Z2", "type": "number" }, "Enabled": { "anyOf": [ { "type": "integer" }, { "type": "null" } ], "default": true, "title": "Enabled" } }, "required": [ "Name", "R1", "Z1", "R2", "Z2" ], "title": "LimiterIn", "type": "object" }, "MeasureIn": { "description": "Measurement input data.", "properties": { "Name": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "title": "Name" }, "Type": { "description": "Measurement type", "enum": [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 18, 17, 19, 20, 21, 22, 23, 24 ], "title": "MeasType", "type": "integer" } }, "required": [ "Name", "Type" ], "title": "MeasureIn", "type": "object" }, "PlasmaIn": { "properties": { "B0": { "title": "B0", "type": "number" }, "R0": { "title": "R0", "type": "number" }, "R0B0": { "anyOf": [ { "type": "number" }, { "type": "null" } ], "default": null, "title": "R0B0" }, "Ip0": { "anyOf": [ { "type": "number" }, { "type": "null" } ], "title": "Ip0" }, "NumBndMomts": { "anyOf": [ { "type": "integer" }, { "type": "null" } ], "default": null, "title": "Numbndmomts" }, "NumPsiPts": { "anyOf": [ { "type": "integer" }, { "type": "null" } ], "title": "Numpsipts" }, "PsiXmax": { "anyOf": [ { "type": "number" }, { "type": "null" } ], "title": "Psixmax" }, "Jedge": { "anyOf": [ { "type": "number" }, { "type": "null" } ], "title": "Jedge" }, "Model": { "discriminator": { "mapping": { "0": "#/$defs/PlasmaModelOld", "1": "#/$defs/PlasmaModelOld", "2": "#/$defs/PlasmaModelOld", "3": "#/$defs/PlasmaModelOld", "4": "#/$defs/PlasmaModelOld", "5": "#/$defs/CDipoleStdIn", "6": "#/$defs/CDipoleIntStableIn", "7": "#/$defs/CDipoleStablePsiNIn", "AnisoFlow": "#/$defs/PlasmaModelOld", "AnisoNoFlow": "#/$defs/PlasmaModelOld", "DipoleIntStable": "#/$defs/CDipoleIntStableIn", "DipoleStablePsiN": "#/$defs/CDipoleStablePsiNIn", "DipoleStd": "#/$defs/CDipoleStdIn", "IsoFlow": "#/$defs/PlasmaModelOld", "IsoNoFlow": "#/$defs/PlasmaModelOld", "Std": "#/$defs/PlasmaModelOld" }, "propertyName": "Type" }, "oneOf": [ { "$ref": "#/$defs/PlasmaModelOld" }, { "$ref": "#/$defs/CDipoleStdIn" }, { "$ref": "#/$defs/CDipoleIntStableIn" }, { "$ref": "#/$defs/CDipoleStablePsiNIn" } ], "title": "Model" } }, "required": [ "B0", "R0", "Ip0", "NumPsiPts", "PsiXmax", "Jedge", "Model" ], "title": "PlasmaIn", "type": "object" }, "PlasmaModelOld": { "description": "Old plasma model data. Covers the standard polynomial models.", "properties": { "Type": { "anyOf": [ { "const": 0, "type": "integer" }, { "const": "Std", "type": "string" }, { "const": "0", "type": "string" }, { "const": 1, "type": "integer" }, { "const": "IsoNoFlow", "type": "string" }, { "const": "1", "type": "string" }, { "const": 2, "type": "integer" }, { "const": "IsoFlow", "type": "string" }, { "const": "2", "type": "string" }, { "const": 3, "type": "integer" }, { "const": "AnisoNoFlow", "type": "string" }, { "const": "3", "type": "string" }, { "const": 4, "type": "integer" }, { "const": "AnisoFlow", "type": "string" }, { "const": "4", "type": "string" } ], "title": "Type" }, "G2pTerms": { "anyOf": [ { "type": "integer" }, { "type": "null" } ], "title": "G2Pterms" }, "HTerms": { "anyOf": [ { "type": "integer" }, { "type": "null" } ], "title": "Hterms" }, "PpTerms": { "anyOf": [ { "type": "integer" }, { "type": "null" } ], "title": "Ppterms" }, "RotTerms": { "anyOf": [ { "type": "integer" }, { "type": "null" } ], "title": "Rotterms" }, "SisoTerms": { "anyOf": [ { "type": "integer" }, { "type": "null" } ], "title": "Sisoterms" }, "SparTerms": { "anyOf": [ { "type": "integer" }, { "type": "null" } ], "title": "Sparterms" }, "SperTerms": { "anyOf": [ { "type": "integer" }, { "type": "null" } ], "title": "Sperterms" }, "G2p": { "anyOf": [ { "items": { "type": "number" }, "type": "array" }, { "type": "null" } ], "title": "G2P" }, "H": { "anyOf": [ { "items": { "type": "number" }, "type": "array" }, { "type": "null" } ], "title": "H" }, "Pp": { "anyOf": [ { "items": { "type": "number" }, "type": "array" }, { "type": "null" } ], "title": "Pp" }, "Rot": { "anyOf": [ { "items": { "type": "number" }, "type": "array" }, { "type": "null" } ], "title": "Rot" }, "Siso": { "anyOf": [ { "items": { "type": "number" }, "type": "array" }, { "type": "null" } ], "title": "Siso" }, "Spar": { "anyOf": [ { "items": { "type": "number" }, "type": "array" }, { "type": "null" } ], "title": "Spar" }, "Sper": { "anyOf": [ { "items": { "type": "number" }, "type": "array" }, { "type": "null" } ], "title": "Sper" } }, "required": [ "Type", "G2pTerms", "HTerms", "PpTerms", "RotTerms", "SisoTerms", "SparTerms", "SperTerms", "G2p", "H", "Pp", "Rot", "Siso", "Spar", "Sper" ], "title": "PlasmaModelOld", "type": "object" }, "PsiGridIn": { "properties": { "Nsize": { "default": 256, "title": "Nsize", "type": "integer" }, "Rmin": { "title": "Rmin", "type": "number" }, "Rmax": { "title": "Rmax", "type": "number" }, "Zmin": { "title": "Zmin", "type": "number" }, "Zmax": { "title": "Zmax", "type": "number" }, "Symmetric": { "anyOf": [ { "type": "boolean" }, { "type": "null" } ], "default": false, "title": "Symmetric" }, "BoundThreshold": { "default": 1e-06, "title": "Boundthreshold", "type": "number" }, "ResThreshold": { "default": 1e-06, "title": "Resthreshold", "type": "number" }, "UnderRelax1": { "anyOf": [ { "type": "number" }, { "type": "null" } ], "default": null, "title": "Underrelax1" }, "UnderRelax2": { "anyOf": [ { "type": "number" }, { "type": "null" } ], "default": null, "title": "Underrelax2" } }, "required": [ "Rmin", "Rmax", "Zmin", "Zmax" ], "title": "PsiGridIn", "type": "object" }, "SeparatrixIn": { "properties": { "Name": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "title": "Name" }, "R1": { "default": 0.0, "title": "R1", "type": "number" }, "Z1": { "title": "Z1", "type": "number" }, "R2": { "default": 0.0, "title": "R2", "type": "number" }, "Z2": { "title": "Z2", "type": "number" }, "RC": { "default": 0.0, "title": "Rc", "type": "number" }, "ZC": { "default": 0.0, "title": "Zc", "type": "number" }, "Enabled": { "anyOf": [ { "type": "boolean" }, { "type": "null" } ], "default": true, "title": "Enabled" } }, "required": [ "Name", "Z1", "Z2" ], "title": "SeparatrixIn", "type": "object" }, "ShellIn": { "description": "(Super) Conducting shell input.", "properties": { "Name": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "title": "Name" }, "Enabled": { "anyOf": [ { "type": "boolean" }, { "type": "null" } ], "default": true, "title": "Enabled" }, "NumSubShells": { "anyOf": [ { "type": "integer" }, { "type": "null" } ], "title": "Numsubshells" }, "SubShells": { "items": { "$ref": "#/$defs/SubShellIn" }, "title": "Subshells", "type": "array" } }, "required": [ "Name", "NumSubShells", "SubShells" ], "title": "ShellIn", "type": "object" }, "SubCoilIn": { "description": "Subcoil input data.", "properties": { "Name": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Name" }, "Fraction": { "title": "Fraction", "type": "number" }, "R": { "title": "R", "type": "number" }, "Z": { "title": "Z", "type": "number" } }, "required": [ "Fraction", "R", "Z" ], "title": "SubCoilIn", "type": "object" }, "SubShellIn": { "description": "Subshell data.", "properties": { "Name": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "title": "Name" }, "Current": { "default": 0.0, "title": "Current", "type": "number" }, "R": { "title": "R", "type": "number" }, "Z": { "title": "Z", "type": "number" } }, "required": [ "Name", "R", "Z" ], "title": "SubShellIn", "type": "object" } }, "required": [ "PsiGrid", "Plasma", "Coils", "Limiters" ] }
- Fields:
- Validators:
check_numbers»all fields
- field Coils: list[CoilIn] [Required]
- Validated by:
- field FitMeasurements: bool | None = False
- Validated by:
- field Iname: str | None = None
- Validated by:
- field Info: str | None = 'DipolEQ Equilibrium'
- Validated by:
- field LHGreenStatus: bool | None = False
- Validated by:
- field LHname: str = ''
- Validated by:
- field Limiters: list[LimiterIn] [Required]
- Validated by:
- field MGname: str = ''
- Validated by:
- field MGreenStatus: bool | None = False
- Validated by:
- field MaxIterFixed: int | None = 0
- Validated by:
- field MaxIterFree: int | None = 50
- Validated by:
- field Measures: list[MeasureIn] | None = None
- Validated by:
- field Name: str | None = 'pyDipolEQ'
- Validated by:
- field NumCoils: int | None = None
- Validated by:
- field NumEqualEq: int | None = 0
- Validated by:
- field NumLimiters: int | None = None
- Validated by:
- field NumMeasures: int | None = None
- Validated by:
- field NumSeps: int | None = None
- Validated by:
- field NumShells: int | None = None
- Validated by:
- field Oname: str | None = None
- Validated by:
- field Plasma: PlasmaIn [Required]
- Validated by:
- field PsiGrid: PsiGridIn [Required]
- Validated by:
- field RSname: str = ''
- Validated by:
- field RestartStatus: bool | None = False
- Validated by:
- field RestartUnkns: bool | None = False
- Validated by:
- field Separatrices: list[SeparatrixIn] | None = None
- Validated by:
- field Shells: list[ShellIn] | None = None
- Validated by:
- field VacuumOnly: bool | None = False
- Validated by:
- validator check_numbers » all fields
check that Num* fields match the number of items in the lists :param Self: the MachineIn object
- Returns:
the MachineIn object, validated
- Return type:
Self