Skip to content

Commit 1a448bd

Browse files
abs(h) symmetry
1 parent 57adc57 commit 1a448bd

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

PyQrackIsing/_pyqrack_ising.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ static inline double expected_closeness_weight(size_t n_rows, size_t n_cols, siz
6767
static inline std::vector<double> probability_by_hamming_weight(double J, double h, double z, double theta, double t, size_t n_qubits)
6868
{
6969
// critical angle
70-
const double theta_c = std::asin(std::max(-1.0, std::min(1.0, (std::abs(z * J) >= (std::numeric_limits<double>::epsilon() / 2)) ? h / (z * J) : (J > 0 ? 1.0 : -1.0))));
70+
const double theta_c = std::asin(std::max(-1.0, std::min(1.0, (std::abs(z * J) >= (std::numeric_limits<double>::epsilon() / 2)) ? std::abs(h) / (z * J) : (J > 0 ? 1.0 : -1.0))));
7171
const double delta_theta = theta - theta_c;
7272
std::vector<double> bias;
7373
if (std::abs(h) < 1e-12) {

scripts/generate_tfim_samples.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def main():
114114
# Coordination number for a square lattice:
115115
z = 4
116116
# Mean-field critical angle (in radians)
117-
theta_c = math.asin(max(min(1, h / (z * J)) if np.isclose(z * J, 0) else (1 if J > 0 else -1), -1))
117+
theta_c = math.asin(max(min(1, abs(h) / (z * J)) if np.isclose(z * J, 0) else (1 if J > 0 else -1), -1))
118118
# Set theta relative to that:
119119
delta_theta = theta - theta_c
120120

scripts/tfim_model_fit.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ def main():
270270
# Coordination number for a square lattice:
271271
z = 4
272272
# Mean-field critical angle (in radians)
273-
theta_c = math.asin(max(min(1, h / (z * J)) if np.isclose(z * J, 0) else (1 if J > 0 else -1), -1))
273+
theta_c = math.asin(max(min(1, abs(h) / (z * J)) if np.isclose(z * J, 0) else (1 if J > 0 else -1), -1))
274274
# Set theta relative to that:
275275
delta_theta = theta - theta_c
276276

scripts/tfim_solver_functions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def tfim_magnetization(J=-1.0, h=2.0, z=4, theta=math.pi/18, t=5, n_qubits=16):
102102
omega *= math.pi
103103

104104
# Mean-field critical angle (in radians)
105-
theta_c = math.asin(max(min(1, h / (z * J)) if np.isclose(z * J, 0) else (1 if J > 0 else -1), -1))
105+
theta_c = math.asin(max(min(1, abs(h) / (z * J)) if np.isclose(z * J, 0) else (1 if J > 0 else -1), -1))
106106
# Set theta relative to that:
107107
delta_theta = theta - theta_c
108108

@@ -173,7 +173,7 @@ def generate_samples(J=-1.0, h=2.0, z=4, theta=math.pi/18, t=5, n_qubits=16, sho
173173
qubits = list(range(n_qubits))
174174

175175
# Mean-field critical angle (in radians)
176-
theta_c = math.asin(max(min(1, h / (z * J)) if np.isclose(z * J, 0) else (1 if J > 0 else -1), -1))
176+
theta_c = math.asin(max(min(1, abs(h) / (z * J)) if np.isclose(z * J, 0) else (1 if J > 0 else -1), -1))
177177
# Set theta relative to that:
178178
delta_theta = theta - theta_c
179179

0 commit comments

Comments
 (0)