Interface for Osborne p-file kinetic profiles.
Example usage:
pf = PFile("p123456.01234")
pf.ne
pf.te
pf.psinorm_for("ne")
"omgeb" in pf
|
| | __contains__ (self, key) |
| | __getitem__ (self, key) |
| | __init__ (self, filename) |
| | Initialize PFile by reading an Osborne p-file from disk.
|
| | __iter__ (self) |
| | __len__ (self) |
| | __repr__ (self) |
| | compute_derivatives (self) |
| | Recompute d(data)/d(psinorm) for all profiles in place.
|
| | compute_diamagnetic_rotations (self, psi, nI=None, TI=None) |
| | Compute diamagnetic rotation frequencies from kinetic profiles.
|
| | compute_pressure (self) |
| | Compute total pressure from density and temperature profiles.
|
| | compute_quasineutrality (self) |
| | Compute impurity density \(n_{z1}\) from quasi-neutrality.
|
| | compute_rotation_decomposition (self, R=None, Bp=None, Bt=None, psi=None) |
| | Compute \(E\times B\) and \(V\times B\) rotation frequencies and derived quantities.
|
| | compute_zeff (self) |
| | Compute the effective charge profile \(Z_{\mathrm{eff}}\).
|
| | derivative_for (self, key) |
| | Return the derivative array for profile key.
|
| | describe (self) |
| | Print a categorised summary of all profiles and derived quantities.
|
| | from_bytes (cls, raw_bytes) |
| | Construct from in-memory bytes.
|
| | new (cls) |
| | Create an empty PFile (no profiles loaded from disk).
|
| | psinorm_for (self, key) |
| | Return the psinorm grid for profile key.
|
| | remap (self, psinorm=None, key="ne") |
| | Return a new PFile with all profiles on a common grid.
|
| | save (self, filename) |
| | Write the profiles to filename in p-file format.
|
| | set_ion_species (self, N, Z, A) |
| | Set the ion species block.
|
| | set_profile (self, key, psinorm, data, derivative=None, units=None) |
| | Add or replace a profile.
|
| | to_bytes (self) |
| | Serialise to in-memory bytes (round-trips with from_bytes).
|
| | units_for (self, key) |
| | Return the units string for profile key.
|
|
| | er = None |
| | Radial electric field \(E_r\) [kV/m].
|
| | ion_species = None |
| | Ion species dict with 'N', 'Z', 'A' arrays, or None.
|
| | keys = None |
| | Profile names in file order (list of str).
|
| | kpol = None |
| | \(K_{\mathrm{POL}} = V_{\mathrm{POL}}/B_p\) [km/s/T]
|
| | nb = None |
| | Fast ion density \(n_b\) [10 \(^{20}\)/m \(^3\)].
|
| | ne = None |
| | Electron density \(n_e\) [10 \(^{20}\)/m \(^3\)].
|
| | ni = None |
| | Ion density \(n_i\) [10 \(^{20}\)/m \(^3\)].
|
| | omeg = None |
| | Toroidal rotation \(V_{\mathrm{TOR}}/R\) [kRad/s].
|
| | omegp = None |
| | Poloidal rotation \(B_t V_{\mathrm{POL}}/(R B_p)\) [kRad/s].
|
| | omgeb = None |
| | \(E\times B\) rotation frequency [kRad/s]
|
| | omghb = None |
| | Hahm-Burrell \(E\times B\) shearing rate.
|
| | omgpp = None |
| | Diamagnetic rotation term [kRad/s].
|
| | omgvb = None |
| | \(V\times B\) rotation term [kRad/s]
|
| | pb = None |
| | Fast ion pressure \(p_b\) [kPa].
|
| | ptot = None |
| | Total pressure \(p_{\mathrm{tot}}\) [kPa].
|
| | te = None |
| | Electron temperature \(T_e\) [keV].
|
| | ti = None |
| | Ion temperature \(T_i\) [keV].
|
| compute_diamagnetic_rotations |
( |
| self, |
|
|
| psi, |
|
|
| nI = None, |
|
|
| TI = None ) |
Compute diamagnetic rotation frequencies from kinetic profiles.
For species \(s\): \(\omega_{\mathrm{dia},s} = \frac{1}{n_s Z_s e}\frac{d(n_s T_s)}{d\psi}\). In p-file units (n in 10 \(^{20}\)/m \(^3\), T in keV, \(\psi\) in Wb) this gives results in kRad/s. Sets omgpp, ommpp, omepp profiles.
- Parameters
-
| psi | Poloidal flux in SI (Weber), same length as the profile grids |
| nI | Impurity density [10 \(^{20}\)/m \(^3\)]; if None, uses nz1 from the p-file when present, otherwise defaults to zero |
| TI | Impurity temperature [keV]; if None, uses ti |
Compute total pressure from density and temperature profiles.
Uses \(p_{\mathrm{tot}} = c_{NT}\,(n_e T_e + (n_i + n_{z1}) T_i) + p_b\) with \(c_{NT}\) converting from (10 \(^{20}\)/m \(^3\) \(\cdot\) keV) to kPa. Requires ne, te, ni, ti on the same psinorm grid. nz1 and pb default to zero if absent. Stores the result as ptot.
| compute_rotation_decomposition |
( |
| self, |
|
|
| R = None, |
|
|
| Bp = None, |
|
|
| Bt = None, |
|
|
| psi = None ) |
Compute \(E\times B\) and \(V\times B\) rotation frequencies and derived quantities.
From the diamagnetic terms (omgpp, ommpp, omepp) and the impurity \(V\times B\) rotation omgvb, computes: omgeb = omgvb + omgpp, ommvb = omgeb - ommpp, omevb = omgeb - omepp. If equilibrium data are provided, also computes er = omgeb * R * Bp and the Hahm-Burrell shearing rate omghb.
- Parameters
-
| R | Midplane major radius [m] on the profile psinorm grid |
| Bp | Poloidal field [T] on the profile psinorm grid |
| Bt | Toroidal field [T] on the profile psinorm grid |
| psi | Poloidal flux in SI (Weber) |
Print a categorised summary of all profiles and derived quantities.
Groups profiles by physics category (kinetic, rotation, impurity, etc.), showing grid length, data range, units, and whether a descriptive label from PFILE_DESCRIPTIONS is known. The ion species block is also printed if present. Access any profile as pf.ne, pf.te, etc. (for common named profiles), or generically via pf['key'] / pf._get_data('key').