torchspin.lft.dtd#
DTD: Townes-Dailey analysis of a 14N quadrupole tensor, differentiable (Telser’s DTD).
Ported from telser-tools (telser_tools_diff.dtd), the default (mode="corrected") path of
telser_tools.dtd. An sp2 nitrogen bound to a metal (pyrrole/imine N of a macrocycle): z along
the M-N bond (the N lone pair), x in the ligand plane, y out of plane; the two N-C sigma bonds lie
in the xz plane at C-N-C angle 2 theta. With orthonormal sp hybrids:
lone pair s character = cot^2 theta, n = (1 - cot^2 theta)/cot^2 theta (sp^n)
n_z = c (1 - cot^2 theta) + b cot^2 theta, n_x = b, n_y = a
P_ii / P0 = n_i - (n_j + n_k)/2 (Townes-Dailey)
c = lone-pair (M-N sigma) population, b = population of EACH N-C sigma hybrid, a = N 2p_pi (y)
population, N_T = c + a + 2b. The model is explicit (linear in the populations), so both
directions are closed forms: batched, every input may carry gradients, torch.func
compatible.
efg_from_populations()-> (P_zz, P_xx, P_yy) (forward)from_angle()->TownesDailey(DTD option ‘D’)from_alphas()->TownesDailey(DTD option ‘A’)
Units#
p0 (the quadrupole coupling of one p electron along its own axis) and the traceless principal
values p_zz, p_xx, p_yy are in any one unit (MHz, as Telser) and with the same sign
convention; the populations depend only on their ratios, and efg_from_populations() returns
the unit of p0. Angles are in radians; degrees=True takes and returns degrees (Telser).
Input validation (c <= 2, 90 < 2 theta < 180 degrees, traceless tensor within trace_tol,
alpha1^2 > 0, …) is done on detached values, for every batch element, and raises ValueError
as telser-tools does. The asymmetry parameter eta involves a sort by abs(P) (decided on
detached values); its derivative is that of the selected branch and does not exist where two
abs(P) tie.
Not ported: mode="fortran" (dtd.f’s pi/180 = 1.745329252e-2 and its IEEE division by zero at
2 theta = 90 degrees), the CLI and the report.
Reference: C. H. Townes, B. P. Dailey, J. Chem. Phys. 1949, 17, 782.
Examples
telser-tools’ DTD quick start: P0 = 10 MHz, 2 theta = 120 degrees, c = 1.5 and (P_zz, P_xx, P_yy) = (3.2, -1.8, -1.4) MHz:
>>> from torchspin.lft import dtd
>>> r = dtd.from_angle(10.0, 120.0, 1.5, 3.2, -1.8, -1.4, degrees=True)
>>> [round(float(x), 4) for x in (r.n, r.a, r.b, r.nt)]
[2.0, 1.0267, 1.0, 4.5267]
>>> round(float(dtd.asymmetry([3.2, -1.8, -1.4])), 4)
0.125
>>> P = dtd.efg_from_populations(10.0, 120.0, r.a, r.b, r.c, degrees=True) # round trip, MHz
>>> [round(x, 4) for x in P.tolist()]
[3.2, -1.8, -1.4]
- class torchspin.lft.dtd.TownesDailey(two_theta, n, c, a, b, nt, alpha1=None)[source]#
Townes-Dailey solution (
from_angle(),from_alphas()).- Variables:
two_theta (Tensor) – C-N-C angle:
from_angle()returns its input unchanged;from_alphas()returns radians, or degrees if called withdegrees=True.n (Tensor) – Lone-pair hybridization sp^n.
b (c, a,) – Populations of the lone pair, the N 2p_pi (y) and each N-C sigma hybrid.
nt (Tensor) – Total population
c + a + 2b.alpha1 (Tensor or None) – Metal coefficient in the M-N sigma* orbital (
from_alphas()only).
- torchspin.lft.dtd.angle_from_hybridization(n, degrees=False)[source]#
C-N-C angle
2 theta = 2 atan(sqrt(n + 1))from the lone-pair sp^n.Returns a float64 tensor in radians (degrees with
degrees=True).
- torchspin.lft.dtd.asymmetry(p)[source]#
Asymmetry parameter
eta = (V_XX - V_YY) / V_ZZof a traceless tensor.The principal values are ordered
abs(V_ZZ) >= abs(V_YY) >= abs(V_XX)on detached values.
- torchspin.lft.dtd.efg_from_populations(p0, two_theta, a, b, c, degrees=False)[source]#
Quadrupole principal values from the orbital populations (forward Townes-Dailey).
- Parameters:
p0 (float or Tensor) – Quadrupole coupling of one N 2p electron along its axis (any unit, e.g. MHz).
two_theta (float or Tensor) – C-N-C angle in radians (degrees with
degrees=True).a (float or Tensor) – Populations of the N 2p_pi (y), of each N-C sigma hybrid and of the lone pair.
b (float or Tensor) – Populations of the N 2p_pi (y), of each N-C sigma hybrid and of the lone pair.
c (float or Tensor) – Populations of the N 2p_pi (y), of each N-C sigma hybrid and of the lone pair.
degrees (bool, default False) – Angle unit of
two_theta.
- Returns:
torch.Tensor, shape (…, 3) – (P_zz, P_xx, P_yy) in the unit of
p0.- Return type:
- torchspin.lft.dtd.from_alphas(p0, alpha2, alpha3, p_zz, p_xx, p_yy, *, degrees=False, trace_tol=1e-6)[source]#
DTD option ‘A’: populations from the N 2s and 2p_z coefficients of the sigma* orbital.
The singly occupied M-N sigma* orbital is
alpha1 d - sum_4N (alpha2 s + alpha3 p_z), so:alpha1^2 = 1 - 4 (alpha2^2 + alpha3^2), n = alpha3^2/alpha2^2, tan^2 theta = n + 1, c = 2 - (alpha2^2 + alpha3^2)
- Parameters:
p0 (float or Tensor) – Quadrupole coupling of one N 2p electron (nonzero).
alpha2 (float or Tensor) – N 2s and 2p_z coefficients:
0 < alpha2 <= 1,0 <= alpha3 <= 1.alpha3 (float or Tensor) – N 2s and 2p_z coefficients:
0 < alpha2 <= 1,0 <= alpha3 <= 1.p_zz (float or Tensor) – Traceless quadrupole principal values, as
from_angle().p_xx (float or Tensor) – Traceless quadrupole principal values, as
from_angle().p_yy (float or Tensor) – Traceless quadrupole principal values, as
from_angle().degrees (bool, default False) – Unit of the returned
two_theta(radians by default).trace_tol (float, default 1e-6) – Allowed
abs(p_zz + p_xx + p_yy).
- Returns:
TownesDailey – Including
alpha1.- Raises:
ValueError – For alpha > 1, alpha2 <= 0, alpha3 < 0,
alpha1^2 <= 0, p0 = 0 and a non-traceless tensor.- Return type:
- torchspin.lft.dtd.from_angle(p0, two_theta, c, p_zz, p_xx, p_yy, *, degrees=False, trace_tol=1e-6)[source]#
DTD option ‘D’: populations from the C-N-C angle and the lone-pair population.
- Parameters:
p0 (float or Tensor) – Quadrupole coupling of one N 2p electron (same unit and sign convention as the P values; nonzero).
two_theta (float or Tensor) – C-N-C angle 2 theta in radians (degrees with
degrees=True), in (90, 180) degrees.c (float or Tensor) – Lone-pair (M-N sigma) population, in [0, 2].
p_zz (float or Tensor) – Traceless quadrupole principal values: z along M-N, x in the ligand plane, y out of plane.
p_xx (float or Tensor) – Traceless quadrupole principal values: z along M-N, x in the ligand plane, y out of plane.
p_yy (float or Tensor) – Traceless quadrupole principal values: z along M-N, x in the ligand plane, y out of plane.
degrees (bool, default False) – Angle unit of
two_theta.trace_tol (float, default 1e-6) – Allowed
abs(p_zz + p_xx + p_yy), in the unit of the P values.
- Returns:
TownesDailey –
two_thetaas given; populations a, b, c and n, nt.- Raises:
ValueError – For c > 2 or c < 0, 2 theta outside (90, 180) degrees (at 90 the equations are singular; below, the lone pair would need more than 100 % s character), p0 = 0, or a tensor that is not traceless within
trace_tol.- Return type: