Skip to content

Commit

Permalink
It runs (but wrong output)
Browse files Browse the repository at this point in the history
  • Loading branch information
vatai committed Jan 21, 2024
1 parent 6221ee0 commit b68184b
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 21 deletions.
25 changes: 23 additions & 2 deletions examples/sctep.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#! /usr/bin/env python

import matplotlib.pyplot as plt
import numpy as np

from radicalpy.data import Isotope, Molecule, Nucleus, Triplet
Expand All @@ -25,16 +26,36 @@ def main(
E=E,
)
print(H)
steady_state_mary(
rhos, Phi_s = steady_state_mary(
sim,
obs_state=State.TP_SINGLET,
obs=State.TP_SINGLET,
Bs=Bs,
D=D,
E=E,
J=J,
theta=np.pi / 4,
phi=0,
kinetics=[Haberkorn(ks, State.TP_SINGLET), HaberkornFree(kd)],
)
rhos *= k0
Phi_s *= k0 * ks

MFE = ((np.abs(Phi_s) - np.abs(Phi_s[0])) / np.abs(Phi_s[0])) * 100
# print(H)
fig = plt.figure(1)
ax = fig.add_axes([0, 0, 1, 1])
ax.set_facecolor("none")
ax.grid(False)
plt.axis("on")
plt.rc("axes", edgecolor="k")
plt.plot(Bs / J, MFE, linewidth=3, color="tab:red")
ax.set_xlabel("g$μ_B$$B_0$ / J", size=18)
ax.set_ylabel("MFE (%)", size=18)
ax.axvline(x=1.5, color="k", linestyle="--")
ax.axvline(x=3, color="k", linestyle="--")
plt.tick_params(labelsize=14)
fig.set_size_inches(8, 5)
plt.show()


if __name__ == "__main__":
Expand Down
29 changes: 10 additions & 19 deletions radicalpy/experiments.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,34 +9,25 @@

def steady_state_mary(
sim: HilbertSimulation,
obs_state: State,
obs: State,
Bs: np.ndarray,
D: float,
E: float,
J: float,
theta: float,
phi: float,
kinetics: list[HilbertIncoherentProcessBase] = [],
relaxations: list[HilbertIncoherentProcessBase] = [],
# relaxations: list[HilbertIncoherentProcessBase] = [],
) -> np.ndarray:
theta = np.pi / 4
phi = 0
HZFS = sim.zero_field_splitting_hamiltonian(D, E)
HJ = sim.exchange_hamiltonian(J)
Phi_s = np.zeros((len(Bs)), dtype=complex)
Ps = sim.projection_operator(State.TP_SINGLET)
rhos = np.zeros(shape=(len(Bs), *HJ.shape))
Q = sim.projection_operator(obs)
for i, B in enumerate(tqdm(Bs)):
HZ = sim.zeeman_hamiltonian_3d(B, theta, phi)
print(f"{HZ.shape=}")
print(f"{HZFS.shape=}")
print(f"{HJ.shape=}")
H = HZ + HZFS + HJ
sim.apply_liouville_hamiltonian_modifiers(H, kinetics + relaxations)
# HL = ry.Hilbert2Liouville(H)
# L = 1j * H + sum(kinetics)
rho = np.linalg.solve(H, Ps) # Density operator
sim.apply_liouville_hamiltonian_modifiers(H, kinetics) # + relaxations)
rhos[i] = np.linalg.solve(H, Q)
Phi_s = sim.product_probability(obs, rhos)

print(f"{type(rho)=} {rho.shape=}")
print(f"{type(Ps)=} {Ps.shape=}")

Phi_s[i] = np.matmul(Ps.T, rho)

return rho, Phi_s
return rhos, Phi_s

0 comments on commit b68184b

Please sign in to comment.