modulation-da 0.0.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- modulation_da/__init__.py +7 -0
- modulation_da/current_calculator.py +71 -0
- modulation_da/exempleBeltako.py +638 -0
- modulation_da/main.py +77 -0
- modulation_da/perturbations.py +103 -0
- modulation_da/pinn_model.py +243 -0
- modulation_da/quantum_config.py +50 -0
- modulation_da/quantum_solver.py +245 -0
- modulation_da/quantum_system.py +51 -0
- modulation_da/results_manager.py +56 -0
- modulation_da/visualization.py +48 -0
- modulation_da-0.0.1.dist-info/METADATA +90 -0
- modulation_da-0.0.1.dist-info/RECORD +16 -0
- modulation_da-0.0.1.dist-info/WHEEL +5 -0
- modulation_da-0.0.1.dist-info/entry_points.txt +2 -0
- modulation_da-0.0.1.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# current_calculator.py
|
|
2
|
+
import tensorflow as tf
|
|
3
|
+
import numpy as np
|
|
4
|
+
|
|
5
|
+
class CurrentCalculator:
|
|
6
|
+
"""Complete calculation of quantum currents"""
|
|
7
|
+
|
|
8
|
+
def __init__(self, config, system):
|
|
9
|
+
self.config = config
|
|
10
|
+
self.system = system
|
|
11
|
+
|
|
12
|
+
def compute_current_contribution(self, model, i_energy, j_mode, perturbation_manager, perturbation_type):
|
|
13
|
+
"""Calculates current contribution for a specific mode/energy"""
|
|
14
|
+
E_norm = self.config.E_min_norm + i_energy * self.config.dE_norm
|
|
15
|
+
psi_st = self.system.stock_psi[i_energy, j_mode, :].reshape((-1, 1))
|
|
16
|
+
psi_st_tensor = tf.convert_to_tensor(psi_st, dtype=tf.complex64)
|
|
17
|
+
|
|
18
|
+
# Prédiction
|
|
19
|
+
t_pred, psi_total, HT_pred = self.predict_wavefunction(model, E_norm, psi_st_tensor, perturbation_manager, perturbation_type)
|
|
20
|
+
|
|
21
|
+
# Current calculation
|
|
22
|
+
fermi_factor = self.system.fermi_dirac(E_norm)
|
|
23
|
+
current_mode = self._compute_mode_current(psi_total, HT_pred, fermi_factor)
|
|
24
|
+
|
|
25
|
+
return current_mode, t_pred
|
|
26
|
+
|
|
27
|
+
def predict_wavefunction(self, model, E_norm, psi_st_tensor, perturbation_manager, perturbation_type):
|
|
28
|
+
"""Predicts the complete wavefunction"""
|
|
29
|
+
t_pred_norm_vals = np.linspace(self.config.t_min_norm, self.config.t_max_norm, 5000)
|
|
30
|
+
t_pred_norm = tf.convert_to_tensor(t_pred_norm_vals.reshape(-1, 1), dtype=tf.float32)
|
|
31
|
+
|
|
32
|
+
# Hamiltonians for prediction
|
|
33
|
+
HP_pred_list = []
|
|
34
|
+
for s in range(len(t_pred_norm_vals)):
|
|
35
|
+
t_s_norm = t_pred_norm_vals[s]
|
|
36
|
+
HP_s = perturbation_manager.get_perturbation(t_s_norm, perturbation_type)
|
|
37
|
+
HP_pred_list.append(HP_s)
|
|
38
|
+
|
|
39
|
+
HP_pred = tf.convert_to_tensor(np.stack(HP_pred_list), dtype=tf.complex64)
|
|
40
|
+
|
|
41
|
+
# Network prediction
|
|
42
|
+
psi_pred = model(t_pred_norm)
|
|
43
|
+
u_pred = psi_pred[:, :self.config.n]
|
|
44
|
+
v_pred = psi_pred[:, self.config.n:]
|
|
45
|
+
psi_p = tf.complex(u_pred, v_pred)
|
|
46
|
+
|
|
47
|
+
# Add stationary state
|
|
48
|
+
phase = tf.exp(-1j * tf.cast(E_norm, tf.complex64) *
|
|
49
|
+
tf.cast(t_pred_norm_vals, tf.complex64))
|
|
50
|
+
phase = tf.expand_dims(phase, axis=-1)
|
|
51
|
+
|
|
52
|
+
psi_st_broadcast = tf.transpose(psi_st_tensor)
|
|
53
|
+
psi_total = psi_p + phase * psi_st_broadcast
|
|
54
|
+
|
|
55
|
+
# Total Hamiltonian
|
|
56
|
+
H_0_tensor = tf.convert_to_tensor(self.system.H_0, dtype=tf.complex64)
|
|
57
|
+
SELF_tensor = tf.convert_to_tensor(self.system.SELF, dtype=tf.complex64)
|
|
58
|
+
|
|
59
|
+
H_0_pred = tf.repeat(tf.expand_dims(H_0_tensor, axis=0), len(t_pred_norm_vals), axis=0)
|
|
60
|
+
SELF_pred = tf.repeat(tf.expand_dims(SELF_tensor, axis=0), len(t_pred_norm_vals), axis=0)
|
|
61
|
+
HT_pred = HP_pred + H_0_pred + SELF_pred
|
|
62
|
+
|
|
63
|
+
return t_pred_norm_vals, psi_total, HT_pred
|
|
64
|
+
|
|
65
|
+
def _compute_mode_current(self, psi_total, HT_pred, fermi_factor):
|
|
66
|
+
"""Calculates current for a specific mode"""
|
|
67
|
+
psi1_conj = tf.math.conj(psi_total[:, 1])
|
|
68
|
+
H12 = HT_pred[:, 1, 2]
|
|
69
|
+
psi2 = psi_total[:, 2]
|
|
70
|
+
|
|
71
|
+
return fermi_factor * psi1_conj * H12 * psi2
|