torchspin.lft.telser2torchspin#
Converters from Josh Telser’s spin-Hamiltonian conventions to torchspin objects.
Telser’s spin-Hamiltonian programs (DDZHQ, DDPOWH, DJDZE, DDPOWJ; ported to Python in telser-tools as
telser_tools.{spin, ddzhq, ddpowh, dimer, djdze, ddpowj}) compute physics that torchspin already has
(ham, levels, resfields, pepper, salt, two-electron systems with exchange). This module
maps Telser’s parameters onto a torchspin.SpinSystem (and an torchspin.Experiment where
an experiment is described), so his inputs run through torchspin. It does not import telser-tools:
parameter objects are read by attribute name (duck typing), and every function also takes plain keywords.
Units#
Inputs follow Telser:
zero-field and exchange energies (D, E, B4q, Telser’s a/F/b, J, j, Ddip, Edip, d, JQ) in
units, default'cm^-1'('MHz','GHz','K','eV'accepted, viatorchspin.lft.units);hyperfine A, U and quadrupole Q in MHz (as Telser);
fields in gauss (
field_units='G', or'mT'/'T'), frequencies in GHz, line widths in MHz (HWHM);angles in degrees (
degrees=True, Telser’s), radians withdegrees=False.
The outputs are torchspin’s: MHz, mT, GHz, radians. The SpinSystem’s couplings are always in MHz.
Map (checked numerically against telser-tools in tests/test_lft_telser2torchspin.py)#
Telser |
torchspin |
|---|---|
g = (gx, gy, gz), g frame = molecular frame |
|
(D/3) O20 + E O22 |
|
B40 O40 + B42 O42 + B44 O44 (Stevens) |
|
a, F, b (cubic, axial, rhombic 4th order) |
B40 = a/120 + F/180, B42 = b/3, B44 = a/24 ( |
u: mu_B sum_k u_k B_k C_k (3rd-order Zeeman) |
|
A, Q principal values + Euler (deg) |
|
g_N of Telser’s table |
|
dimer: + J S1.S2 (J > 0 antiferromagnetic) |
|
dimer: j[(S1.S2)^2 - X1 X2/3] |
|
dimer: 24 JQ T2(S1).T2(S2) (S1, S2 >= 1) |
|
dimer: site g2, D2 Euler angles |
|
EPR half width W_k (MHz, HWHM, frequency) |
|
ENDOR line half width w (MHz) |
|
H1 mode 0 / < 0 |
|
populations at T |
|
Telser’s exchange convention is EasySpin’s (H = +J S1.S2). Other conventions are converted with
J_convention (telser_J()): H = -2J’ S1.S2 (Heisenberg-Dirac-van Vleck, Bleaney-Bowers) is
J_convention='-2J'.
Transition probabilities: Telser’s (telser-tools exact mode) B1-averaged P is normalized so that S = 1/2,
g = 2 gives 1. torchspin’s rate (abs(mu)^2 - abs(n.mu)^2)/2 is mu_B^2 P (with the nuclear moment, which Telser
leaves out by default); resfields intensities are mu_B^2 P/(2I + 1)/abs(dE/dB).
w becomes Sys.Ham lB = 2 rows (run with Options(QuadraticZeeman=True); extras['options']), U a
Sys.H0Extra term, and a zero field a true Field = 0 (Options(ZeroField=True), per spectrum in
extras['spectra']). Not mapped for pepper (see docs/lft_gap_analysis.md): NMR/NQR powder spectra
(S = 0; the nuclear SpinSystem itself is built), the DDPOWH/DDPOWJ strain models, Lorentzian
frequency-domain widths for ENDOR (salt has no Lorentzian strain) and mixed H1 modes. With strict=True (default) these
raise NotImplementedError; with strict=False they are dropped with a warning and listed in
TelserConversion.extras['dropped']. Telser’s Flygare frequency factor has no counterpart either; compare
with telser-tools’ frequency_factor=False. ddpowh2sys/ddpowj2sys with target='lft' map all of
these for torchspin.lft.ddpowh / torchspin.lft.ddpowj (Telser’s field-point model on the
SpinSystem; w and U through second_order_zeeman_operator() and u_term_operator()).
Constants: torchspin uses CODATA 2022 mu_B, telser-tools CODATA 2018 (1.4e-9 apart). constants= takes
a telser-tools Constants-like object (mu_b_mhz and mu_n_mhz in MHz/G, mu_b_cm in cm^-1/G);
g, u and g_N are then rescaled so that torchspin’s Hamiltonian equals Telser’s at the same field (and
cm^-1 -> MHz uses its mu_b_mhz/mu_b_cm). This is for parity tests: the g values in the SpinSystem
are then effective values, not the entered ones.
Gradients: g, D, E, B4q, A, Q principal values, U, J, j, Ddip, Edip, d, JQ and all Euler angles may be
tensors and keep their graph, with or without full_tensors (the frames gFrame/AFrame/DFrame/
QFrame stay on the graph in torchspin’s ham). The second- and third-order Zeeman coefficients w and
u are converted to floats (detached) by second_order_zeeman_ham() and third_order_zeeman_ham();
second_order_zeeman_operator() keeps w on the graph.
- class torchspin.lft.telser2torchspin.TelserConversion(sys, exp, extras)[source]#
Result of a program converter (
ddzhq2sys(),ddpowh2sys(),djdze2sys(),ddpowj2sys()).- Variables:
sys (SpinSystem) – The converted
torchspin.SpinSystem(couplings in MHz).exp (Experiment or None) – A
torchspin.Experimentwhere the input describes one.extras (dict) – As present:
'dropped'(features not mapped,strict=False),'notes','options'(torchspin.Optionskeywords the run needs, e.g.QuadraticZeeman=Truefor w;ZeroField=Trueper zero-field spectrum in'spectra'),'energy_offset'(MHz; Telser’s levels = torchspin’s + offset),'cycles'(DDZHQ/DJDZE field points),'spectra'(DDPOWH/DDPOWJ per-spectrum experiments and settings),'h1mode','target'.
- sys: SpinSystem#
Alias for field number 0
- exp: Experiment | None#
Alias for field number 1
- torchspin.lft.telser2torchspin.MU_B_MHZ_PER_MT = 13.996244917056908#
mu_B/h and mu_N/h in MHz per mT, from
torchspin.constants(what torchspin’s Hamiltonian uses).
- torchspin.lft.telser2torchspin.abf_to_stevens(a=0.0, F=0.0, b=0.0)[source]#
Stevens (B40, B42, B44) from Telser’s a (cubic), F (axial) and b (rhombic) 4th-order parameters.
The cubic term is (a/120)(O40 + 5 O44), so B40 = a/120 + F/180, B42 = b/3, B44 = a/24 (
telser_tools.spin.SpinParameters.from_abf; ddzhqea.f ll. 161-175). Same units in and out; tensors keep their graph.Examples
>>> from torchspin.lft import telser2torchspin as t2 >>> t2.abf_to_stevens(120.0, 180.0, 3.0) (2.0, 1.0, 5.0)
- torchspin.lft.telser2torchspin.stevens_to_abf(B40=0.0, B42=0.0, B44=0.0)[source]#
Inverse of
abf_to_stevens(): (a, F, b) = (24 B44, 180 (B40 - B44/5), 3 B42).Examples
>>> from torchspin.lft import telser2torchspin as t2 >>> t2.stevens_to_abf(2.0, 1.0, 5.0) (120.0, 180.0, 3.0)
- torchspin.lft.telser2torchspin.zfs_principal(D, E)[source]#
Principal values (-D/3 + E, -D/3 - E, 2D/3) of (D/3) O20 + E O22 written as S.D.S.
Same units in and out; returns a tensor of shape (3,) (graph-safe).
Examples
>>> from torchspin.lft import telser2torchspin as t2 >>> t2.zfs_principal(3.0, 0.5).tolist() [-0.5, -1.5, 2.0]
- torchspin.lft.telser2torchspin.euler_matrix(alpha, beta, gamma, *, degrees=False)[source]#
McGavin z-y’-z’’ rotation R = Rz(alpha) Ry(beta) Rz(gamma) of Telser’s DEULER.F (graph-safe).
- Parameters:
- Returns:
torch.Tensor, shape (3, 3) – R; its columns are the rotated axes in the molecular frame, and a tensor with principal values t is
R diag(t) R^Tin the molecular frame. EasySpin/torchspin frames (AFrame,gFrame, …) with the same angles give the same tensor.- Return type:
- torchspin.lft.telser2torchspin.rotate_tensor(principal, angles=(0.0, 0.0, 0.0), *, degrees=False)[source]#
Molecular-frame tensor
R diag(principal) R^Twith R =euler_matrix()(graph-safe).
- torchspin.lft.telser2torchspin.telser_J(J, convention='+J')[source]#
Exchange J in Telser’s (and EasySpin’s) convention H = +J S1.S2.
- Parameters:
- Returns:
float or torch.Tensor – J in the +J convention, same units.
- Raises:
ValueError – For an unknown convention.
Examples
J’ = -10 cm^-1 in -2J’ S1.S2 (ferromagnetic) is +20 cm^-1 here:
>>> from torchspin.lft import telser2torchspin as t2 >>> t2.telser_J(-10.0, '-2J') 20.0
- torchspin.lft.telser2torchspin.antisymmetric_tensor(d)[source]#
3x3 tensor T with S1.T.S2 = d.(S1 x S2) (antisymmetric, Dzyaloshinskii-Moriya).
- Parameters:
d (array_like, shape (3,)) – The vector d, in any energy unit (graph-safe).
- Returns:
torch.Tensor, shape (3, 3)
- Return type:
- torchspin.lft.telser2torchspin.exchange_tensor(J=0.0, Ddip=0.0, Edip=0.0, dip_euler=(0.0, 0.0, 0.0), d=(0.0, 0.0, 0.0), *, degrees=True)[source]#
Full 3x3 coupling S1.T.S2 = J S1.S2 + S1.Ddip.S2 + d.(S1 x S2) (Telser’s DJDZE/DDPOWJ terms).
- Parameters:
J (float or Tensor, default 0.0) – Isotropic exchange (+J convention).
Ddip (float or Tensor, default 0.0) – Anisotropic (dipolar) coupling:
R diag(-Ddip/3 + Edip, -Ddip/3 - Edip, 2Ddip/3) R^T.Edip (float or Tensor, default 0.0) – Anisotropic (dipolar) coupling:
R diag(-Ddip/3 + Edip, -Ddip/3 - Edip, 2Ddip/3) R^T.dip_euler (array_like, shape (3,), default (0, 0, 0)) – Euler angles of R, in degrees (radians with
degrees=False).d (array_like, shape (3,), default (0, 0, 0)) – Antisymmetric exchange vector.
degrees (bool, default True)
- Returns:
torch.Tensor, shape (3, 3) – In the units of the inputs (graph-safe).
- Return type:
- torchspin.lft.telser2torchspin.third_order_zeeman_ham(s, u, *, mu_b=MU_B_MHZ_PER_MT, electron=0, n_electrons=1)[source]#
SpinSystem.Hamentries for Telser’s third-order Zeeman term mu_B sum_k u_k B_k C_k.C_k = S_k^3 - (3X - 1)/5 S_k (X = S(S+1)). The term is linear in B, with spin rank 3 and coupling ranks l = 2 and 4 (
'132','134'; for ux = uy = uz only l = 4, the cubic invariant).- Parameters:
s (float) – Electron spin, S >= 3/2.
u (float or array_like, shape (3,)) – Dimensionless (ux, uy, uz), or one value. Converted to floats (detached).
mu_b (float, default MU_B_MHZ_PER_MT) – mu_B/h in MHz/mT.
electron (int, default 0) – 0-based row of a multi-electron system.
n_electrons (int, default 1) – Number of rows (the other rows are zero).
- Returns:
dict –
{'132': rows, '134': rows}(lists ofn_electronsrows).- Raises:
ValueError – If
s < 3/2.- Return type:
- torchspin.lft.telser2torchspin.isotope_for(spin, label=None)[source]#
torchspin isotope name for a nucleus of spin I given by Telser’s label.
- Parameters:
- Returns:
str – The labeled isotope, or a representative isotope with spin I (the nuclear g value is then set through
gnscale).- Raises:
ValueError – If no stand-in isotope with spin I exists.
- Return type:
Examples
>>> from torchspin.lft import telser2torchspin as t2 >>> t2.isotope_for(1.0, '14N'), t2.isotope_for(2.5) ('14N', '17O')
- torchspin.lft.telser2torchspin.dimer_energy_offset(s1, s2, j=0.0, JQ=0.0, *, units='cm^-1', constants=None)[source]#
Telser’s dimer levels minus torchspin’s, in MHz: -(j + 24 JQ) X1 X2/3.
Telser’s biquadratic term is j[(S1.S2)^2 - X1 X2/3] (X = S(S+1)); torchspin’s
ee2has no constant. The isotropic quadrupole term 24 JQ T2(S1).T2(S2) = 24 JQ [(S1.S2)^2 + S1.S2/2 - X1 X2/3] counts only for S1, S2 >= 1.- Parameters:
- Returns:
float – Offset in MHz.
- torchspin.lft.telser2torchspin.spin2sys(params=None, *, s=None, g=None, w=None, u=None, D=None, E=None, B40=None, B42=None, B44=None, a=None, F=None, b=None, nucleus=None, I=None, g_n=None, A=None, A_euler=None, U=None, Q=None, Q_euler=None, isotope=None, units='cm^-1', degrees=True, constants=None, full_tensors=False, strict=True, dropped=None, **sys_kwargs)[source]#
SpinSystem of one electron spin S (and at most one nucleus) in Telser’s DDZHQ/DDPOWH parameterization.
- Parameters:
params (object or dict, optional) – A telser-tools
spin.SpinParametersor any object/dict withs, g, w, u, D, E, B40, B42, B44, nucleus; the nucleus withspin, g_n, A, A_euler, U, Q, Q_euler, label. The keywords below override it.s (float, optional) – Electron spin (default 0.5).
s = 0gives a nuclear spin system (S=[]: quadrupole and nuclear Zeeman), DDPOWH’s NMR/NQR case.g (array_like, shape (3,), optional) – Principal g values in the molecular frame (default (2, 2, 2)).
w (float or Tensor, optional) – Second-order Zeeman w (1/
units), S >= 1; becomesSys.HamlB = 2 rows (second_order_zeeman_ham(), detached); pepper, resfields and levels needOptions(QuadraticZeeman=True)(quadratic_zeeman_options()).u (array_like, shape (3,), optional) – Third-order Zeeman u (dimensionless), S >= 3/2 (
third_order_zeeman_ham()).D (float or Tensor, optional) – Zero-field splitting in
units, S >= 1.E (float or Tensor, optional) – Zero-field splitting in
units, S >= 1.B40 (float or Tensor, optional) – 4th-order Stevens coefficients in
units, S >= 2.B42 (float or Tensor, optional) – 4th-order Stevens coefficients in
units, S >= 2.B44 (float or Tensor, optional) – 4th-order Stevens coefficients in
units, S >= 2.a (float or Tensor, optional) – Telser’s 4th-order form (
units), added to B40, B42, B44 (abf_to_stevens()).F (float or Tensor, optional) – Telser’s 4th-order form (
units), added to B40, B42, B44 (abf_to_stevens()).b (float or Tensor, optional) – Telser’s 4th-order form (
units), added to B40, B42, B44 (abf_to_stevens()).nucleus (object or dict, optional) – The nucleus (overrides
params.nucleus).I (float, optional) – Nuclear spin (overrides
nucleus.spin).g_n (float or Tensor, optional) – Nuclear g value; set through
gnscale.A (array_like, shape (3,), optional) – Hyperfine principal values in MHz.
A_euler (array_like, shape (3,), optional) – Euler angles of A and Q (degrees unless
degrees=False).Q_euler (array_like, shape (3,), optional) – Euler angles of A and Q (degrees unless
degrees=False).U (float or Tensor, optional) – I.S^3 hyperfine U in MHz (S >= 3/2): becomes a
Sys.H0Extraterm (u_term_operator(), differentiable in U).Q (array_like, shape (3,), optional) – Quadrupole principal values in MHz (I >= 1).
isotope (str, optional) – torchspin isotope name; default from the label (
isotope_for()).units (str, default 'cm^-1') – Unit of D, E, B4q, a, F, b and 1/w.
degrees (bool, default True) – Euler angles in degrees.
constants (object, optional) – telser-tools
Constants(parity tests; module docstring).full_tensors (bool, default False) – Pass A and Q as full 3x3 tensors instead of principal values and frames.
strict (bool) – Accepted for the program converters;
droppedcollects dropped features.dropped (list | None) – Accepted for the program converters;
droppedcollects dropped features.**sys_kwargs – Passed to
torchspin.SpinSystem(HStrain,lw, …);Hamis merged with the generated entries.
- Returns:
SpinSystem – Couplings in MHz, angles in radians. Tensor inputs keep their graph (except w and u).
- Raises:
ValueError – If
s = 0without a nucleus of I >= 1/2, or a 3-vector input has the wrong shape.TypeError – If
sys_kwargssets a field this function sets.
- Return type:
Examples
An S = 3/2 system with D = 1 cm^-1, E = 0.1 cm^-1 (couplings converted to MHz):
>>> from torchspin.lft import telser2torchspin as t2 >>> sys = t2.spin2sys(s=1.5, g=(2.0, 2.0, 2.0), D=1.0, E=0.1) >>> sys.S, [round(v) for v in sys.D[0].tolist()] ([1.5], [-6995, -12991, 19986])
- torchspin.lft.telser2torchspin.dimer2sys(params=None, *, site1=None, site2=None, J=None, j=None, Ddip=None, Edip=None, dip_euler=None, d=None, JQ=None, J_convention='+J', units='cm^-1', degrees=True, constants=None, full_tensors=False, **sys_kwargs)[source]#
SpinSystem of Telser’s exchange-coupled dimer (DJDZE, DDPOWJ): two electron spins S1, S2.
H = sum_i [mu_B B.g_i.S_i + S_i.D_i.S_i + B4q_i O4q + mu_i mu_B sum_k B_k C_k(S_i)] + J S1.S2 + S1.Ddip.S2 + d.(S1 x S2) + j[(S1.S2)^2 - X1X2/3] + 24 JQ T2(S1).T2(S2), all tensors in the site-1 frame. The coupling becomes the full 3x3
ee(MHz) andee2; levels differ from Telser’s by the constantdimer_energy_offset(). A site with S = 0 is left out (a one-electron SpinSystem).- Parameters:
params (object or dict, optional) – A telser-tools
dimer.DimerParameters(site1,site2,coupling) or anything with those attributes.site1 (object or dict, optional) – Sites with
s, g, g_euler, D, E, D_euler, B40, B42, B44, mu(energies inunits, angles in degrees unlessdegrees=False;muis the third-order Zeeman u of the site, S >= 3/2).site2 (object or dict, optional) – Sites with
s, g, g_euler, D, E, D_euler, B40, B42, B44, mu(energies inunits, angles in degrees unlessdegrees=False;muis the third-order Zeeman u of the site, S >= 3/2).J (float or Tensor, optional) – Coupling (
units);JinJ_convention.j (float or Tensor, optional) – Coupling (
units);JinJ_convention.Ddip (float or Tensor, optional) – Coupling (
units);JinJ_convention.Edip (float or Tensor, optional) – Coupling (
units);JinJ_convention.JQ (float or Tensor, optional) – Coupling (
units);JinJ_convention.dip_euler (array_like, shape (3,), optional) – Euler angles of Ddip.
d (array_like, shape (3,), optional) – Antisymmetric exchange vector (
units).J_convention (str, default '+J') – See
telser_J()('-2J'for H = -2J S1.S2).units (str, default 'cm^-1')
degrees (bool, default True)
constants (object, optional) – telser-tools
Constants(parity tests).full_tensors (bool, default False) – Pass g and D as full 3x3 tensors instead of principal values and frames.
**sys_kwargs – Passed to
torchspin.SpinSystem.
- Returns:
SpinSystem – Couplings in MHz. Tensor inputs keep their graph.
- Raises:
ValueError – If both sites have S = 0.
NotImplementedError – For 4th-order terms on a site with a nonzero
D_euler.TypeError – If
sys_kwargssets a field this function sets.
- Return type:
Examples
Two S = 1/2 sites with J’ = -10 cm^-1 in -2J’ S1.S2:
>>> from torchspin.lft import telser2torchspin as t2 >>> site = dict(s=0.5, g=(2.0, 2.0, 2.0)) >>> dimer = t2.dimer2sys(site1=site, site2=site, J=-10.0, J_convention='-2J') >>> round(float(dimer.ee[0, 0])) # +20 cm^-1 in MHz 599585
- torchspin.lft.telser2torchspin.epr_experiment(freq_ghz, field_range, npts, *, field_units='G', deriv=0, temperature=None, h1mode=0.0, strict=True, dropped=None)[source]#
torchspin.Experimentof a Telser field sweep.- Parameters:
freq_ghz (float) – Microwave frequency in GHz.
field_range (sequence of 2 float) – (Bmin, Bmax) in
field_units.npts (int) – Number of intervals; the Experiment has
npts + 1points, as DDPOWH/DDPOWJ write them.field_units ({'G', 'mT', 'T'}, default 'G')
deriv (int, default 0) – Derivative flag ->
Harmonic(the exact-mode d/dB of telser-tools is pepper’sHarmonic=1).temperature (float, optional) – K; sets
Temperature.h1mode (float, default 0.0) – 0 perpendicular,
< 0parallel;> 0(mixed) is not mapped.strict (bool, default True) – Raise for a mixed mode (
False: drop it with a warning).dropped (list, optional) – Collects dropped features.
- Returns:
Experiment
- Raises:
NotImplementedError – For
h1mode > 0withstrict=True.- Return type:
Examples
>>> from torchspin.lft import telser2torchspin as t2 >>> exp = t2.epr_experiment(9.5, (3000, 4000), 400) >>> exp.Range, exp.nPoints, exp.Mode ([300.0, 400.0], 401, 'perpendicular')
- torchspin.lft.telser2torchspin.ordering(lam_x, lam_z)[source]#
Experiment.Orderingcallable for DDPOWH’s partial orientation ORFACT.ORFACT = exp(lam_x cos^2(phi) + lam_z cos^2(theta)) with (theta, phi) the field direction in the molecular frame. With the field along the lab z axis, the molecular frame at EasySpin Euler angles (alpha, beta, gamma) sees it at theta = beta, phi = pi - gamma, so the weight is exp(lam_x cos^2(gamma) + lam_z cos^2(beta)), independent of alpha.
- Parameters:
- Returns:
callable –
f(alpha, beta, gamma)(radians, arrays) fortorchspin.ExperimentOrdering.
- torchspin.lft.telser2torchspin.ddzhq2sys(inp, *, constants=None, full_tensors=False, strict=True, **sys_kwargs)[source]#
A DDZHQ input as SpinSystem + field points.
Exact-mode semantics of telser-tools: the Bnm-form B44 is the Stevens coefficient (finding DDZHQ-06), and zero field is a real zero field.
- Parameters:
inp (object) – A telser-tools
ddzhq.DdzhqInput(read by attribute).constants (object, optional) – telser-tools
Constants(parity tests; module docstring).full_tensors (bool, default False) – Full 3x3 A and Q tensors instead of principal values and frames.
strict (bool, default True) – Raise
NotImplementedErrorfor unmapped features (False: drop them with a warning, listed inextras['dropped']).**sys_kwargs – Passed to
torchspin.SpinSystem.
- Returns:
TelserConversion –
sys;exp, an Experiment at the input’s frequency (Modefrom the H1 mode,Temperatureif populations are on) fortorchspin.resfields;extras['cycles'], one dict per computed cycle in input order withfield_mT,theta/phi(radians, field direction in the molecular frame),direction(unit 3-vector),g_effandzero_field. A g-value entry is converted to the field nu/(mu_B g).- Return type:
- torchspin.lft.telser2torchspin.ddpowh2sys(inp, *, constants=None, full_tensors=False, strict=True, target='pepper', **sys_kwargs)[source]#
A DDPOWH input as SpinSystem + Experiment(s), for pepper/salt or for
torchspin.lft.ddpowh.With
target='pepper'(default):Field-swept EPR (kind
'E'):expfortorchspin.pepper()(Range in mT, npts + 1 points, Harmonic = derivative flag, Temperature with populations).FDMR (
'F'): one frequency-swept Experiment per spectrum (Fieldin mT,mwRangein GHz) inextras['spectra'];expis the first.ENDOR (
'N'): one fixed-field Experiment per spectrum (Field,mwFreq,ExciteWidth=1e-3) and thetorchspin.salt()keywordsfreq_range(MHz, absolute; for a centered axis the Larmor frequency is added) andlw_mhz= 2 w (Telser’s NMR half width w), inextras['spectra']. Telser selects orientations with the EPR line itself (HStrain= 2 W here, ExciteWidth ~ 0 in salt).
The EPR half widths W (MHz, HWHM) become
HStrain = 2 W, orHStrainL = 2 Wfor Telser’s Lorentzian frequency-domain line in EPR and FDMR (extras['notes']: Telser cuts the line at ICUTOFF half widths, pepper does not). Not mapped for pepper: the Lorentzian line for ENDOR (salt’s selection is Gaussian), the Flygare frequency factor (compare with telser-tools’frequency_factor=False), the DDPOWH strain model, ORFACT (useordering()), the <g^2> normalization (a constant) and NMR/NQR spectra (S = 0).target='lft'maps every feature instead, fortorchspin.lft.ddpowh(Telser’s own field-point model): strain, Lorentzian lines, w, U, the Flygare factor, the cutoff, m_S-manifold pair selection, ORFACT, <g^2>, mixed H1 modes, zero-field FDMR/ENDOR and S = 0 NMR/NQR; nothing is dropped.extras['spectra']then holds, per spectrum,func('epr','fdmr','endor','nmr'),kwargs(everything but the SpinSystem),x(Telser’s axis as entered) andx_unit; run them withtorchspin.lft.ddpowh.simulate().- Parameters:
inp (object) – A telser-tools
ddpowh.DdpowhInput(read by attribute).constants – As
ddzhq2sys().full_tensors (bool) – As
ddzhq2sys().strict (bool) – As
ddzhq2sys().**sys_kwargs – As
ddzhq2sys().target ({'pepper', 'lft'}, default 'pepper')
- Returns:
TelserConversion
- Raises:
ValueError – For an unknown
target.NotImplementedError – With
strict=Trueandtarget='pepper', for a feature that cannot be mapped (listed above).
- Return type:
- torchspin.lft.telser2torchspin.djdze2sys(inp, *, constants=None, full_tensors=False, **sys_kwargs)[source]#
A DJDZE input as a two-electron SpinSystem + field points.
Site 2’s g and D are rotated by the same Euler angles (DJDZE).
- Parameters:
inp (object) – A telser-tools
djdze.DjdzeInput(read by attribute).constants – As
dimer2sys().full_tensors (bool) – As
dimer2sys().**sys_kwargs – As
dimer2sys().
- Returns:
TelserConversion –
exp: an Experiment if the input sets up EPR, elseNone;extras['energy_offset'](MHz) is added to torchspin’s levels to get Telser’s;extras['cycles']lists the field points (field_mT,theta,phiin radians,direction,zero_field) as DJDZE visits them (a zero field keeps the previous orientation).- Return type:
- torchspin.lft.telser2torchspin.ddpowj2sys(inp, *, constants=None, full_tensors=False, strict=True, target='pepper', s12_strain_weight=0.0, **sys_kwargs)[source]#
A DDPOWJ input as a two-electron SpinSystem + pepper Experiment, or for
torchspin.lft.ddpowj.Site 2’s g and D have separate Euler angles (DDPOWJ v5.0). With
target='pepper': W (MHz, HWHM) ->HStrain = 2 W(Lorentzian lines:HStrainL = 2 W, Telser’s ICUTOFF truncation listed inextras['notes']); the DDPOWJ strain model is not mapped. UseOptions(Threshold=0)in pepper: its default transition pruning drops weak singlet-triplet lines.target='lft'maps everything (strain, Lorentzian lines, level ranges, Flygare factor, cutoff, mixed H1 modes);extras['spectra'][0]holdsfunc='epr'and itskwargs.- Parameters:
inp (object) – A telser-tools
ddpowj.DdpowjInput(read by attribute).constants – As
ddzhq2sys()/dimer2sys().full_tensors (bool) – As
ddzhq2sys()/dimer2sys().strict (bool) – As
ddzhq2sys()/dimer2sys().**sys_kwargs – As
ddzhq2sys()/dimer2sys().target ({'pepper', 'lft'}, default 'pepper')
s12_strain_weight (float, default 0.0) –
target='lft': strain weight of S = 1/2 (and S = 0) sites, 0.0 (exact) or 1.0 (the Fortran, DDPOWJ-10; seetorchspin.lft.ddpowj).
- Returns:
TelserConversion – With
extras['energy_offset'](MHz).- Raises:
ValueError – For an unknown
target.NotImplementedError – With
strict=Trueandtarget='pepper', for the strain model or a mixed H1 mode.
- Return type:
- class torchspin.lft.telser2torchspin.QuadrupoleEcho(p_par, eta, e2qQ)[source]#
DDZHQ’s quadrupole echo (MHz, tensors).
- Variables:
- torchspin.lft.telser2torchspin.quadrupole_echo(Q, I)[source]#
P_par, eta and e^2qQ/h of traceless quadrupole principal values.
The axes are relabeled so that
abs(Q_zz) >= abs(Q_yy) >= abs(Q_xx)(0 <= eta <= 1), the standard definition that telser-tools’ exact mode prints (the Fortran’s echo has eta <= 0, finding DDZHQ-08).[e2qQ, eta]is torchspin’s two-valueSpinSystem.Qform.- Parameters:
- Returns:
QuadrupoleEcho or None –
Noneif Q = 0.- Raises:
ValueError – If
I < 1.- Return type:
QuadrupoleEcho | None
Examples
>>> from torchspin.lft import telser2torchspin as t2 >>> [round(float(x), 3) for x in t2.quadrupole_echo([-0.3, -0.7, 1.0], 1.0)] [1.5, 0.4, 2.0]
- torchspin.lft.telser2torchspin.spin_projections(sys, field_mT, direction)[source]#
Spin projections <k|S_i|k>.n of every eigenstate k and electron i (DJDZE’s spin magnitudes).
telser-tools’ exact form (the projection of each site’s spin on the field direction n; the Fortran’s sum_k <S_k> n_k^2 is finding DJDZE-07), with torchspin’s Hamiltonian H0 - B.mu. Within a degenerate level only the sum over the level is basis-free.
- Parameters:
sys (SpinSystem)
field_mT (float) – Field magnitude in mT.
direction (array_like, shape (3,)) – Unit field direction in the molecular frame.
- Returns:
torch.Tensor, shape (nStates, nElectrons) – Rows in ascending energy.
- Return type:
- torchspin.lft.telser2torchspin.second_order_zeeman_operator(sys, w, *, electron=0, units='cm^-1', constants=None)[source]#
Second-order Zeeman operator Z2 with H += B^2 n.Z2.n = w (mu_B B.S)^2, for
torchspin.lft.ddpowh.torchspin’s
levels,resfieldsandpeppercarry only the part of H linear in B; pass this aszeeman2=totorchspin.lft.ddpowh.epr()and friends. Graph-safe inw.- Parameters:
- Returns:
torch.Tensor, shape (3, 3, n, n) – Complex, MHz/mT^2.
- Return type:
- torchspin.lft.telser2torchspin.u_term_operator(sys, U, *, electron=0, nucleus=0)[source]#
Telser’s I.S^3 hyperfine term U sum_k C_k(S) I_k, for
torchspin.lft.ddpowh(h0_extra=).C_k = S_k^3 - (3X - 1)/5 S_k, X = S(S+1).
spin2sys()adds it toSpinSystem.H0Extra. Graph-safe inU.- Parameters:
sys (SpinSystem)
electron (int, default 0) – 0-based electron (S >= 3/2) and nucleus.
nucleus (int, default 0) – 0-based electron (S >= 3/2) and nucleus.
- Returns:
torch.Tensor, shape (n, n) – Complex, MHz.
- Raises:
ValueError – If the electron has S < 3/2.
- Return type:
- torchspin.lft.telser2torchspin.second_order_zeeman_ham(s, w, *, mu_b=MU_B_MHZ_PER_MT, units='cm^-1', constants=None, electron=0, n_electrons=1)[source]#
SpinSystem.Hamentries (lB = 2) for Telser’s second-order Zeeman term w (mu_B B.S)^2.The returned rows reproduce w mu_B^2 [(B.S)^2 - B^2 X/3] (X = S(S+1)): the dropped part is proportional to the identity, shifts all levels by w mu_B^2 B^2 X/3 and leaves transitions unchanged (Telser’s levels = torchspin’s +
second_order_zeeman_offset()).levels,resfieldsandpepperinclude the term only withOptions(QuadraticZeeman=True);ham(sys, B0)always does.- Parameters:
s (float) – Electron spin, S >= 1.
w (float or Tensor) – w in 1/
units(Telser: 1/cm^-1); converted to a float (detached; usesecond_order_zeeman_operator()for gradients in w).mu_b (float, default MU_B_MHZ_PER_MT) – mu_B/h in MHz/mT.
units (str, default 'cm^-1')
constants (object, optional) – telser-tools
Constantsfor the cm^-1 -> MHz factor.electron (int, default 0, 1) – Row selection, as
third_order_zeeman_ham().n_electrons (int, default 0, 1) – Row selection, as
third_order_zeeman_ham().
- Returns:
dict –
{'220': rows, '222': rows, '224': rows}.- Raises:
ValueError – If
s < 1.- Return type:
- torchspin.lft.telser2torchspin.second_order_zeeman_offset(s, w, field_mT, *, mu_b=MU_B_MHZ_PER_MT, units='cm^-1', constants=None)[source]#
Level shift w mu_B^2 B^2 X/3 in MHz: Telser’s levels minus torchspin’s for
second_order_zeeman_ham().field_mTin mT; other arguments assecond_order_zeeman_ham(). Graph-safe inw.