"""Wilmot crisis apparition (Case C.9) – dual percipient, veridical detail (upper berth)."""
import matplotlib.pyplot as plt
import numpy as np
from mercurial.core.neural_field import NeuralField2D
from mercurial.simulation.engine import SimulationEngine
[docs]
def run_wilmot():
engine = SimulationEngine(dim=20)
engine.apply_empirical_parameters()
nx, ny = 32, 32
observer1 = NeuralField2D(nx, ny, dx=0.5, wc_params=engine.wc_params.__dict__)
observer2 = NeuralField2D(nx, ny, dx=0.5, wc_params=engine.wc_params.__dict__)
X, Y = np.meshgrid(np.linspace(-2, 2, nx), np.linspace(-2, 2, ny))
apparition_pattern = np.exp(-((X - 0.2) ** 2 + (Y + 0.3) ** 2) / 0.1) + 0.7 * np.exp(
-((X + 0.1) ** 2 + (Y - 0.2) ** 2) / 0.12
)
upper_berth = 0.8 * np.exp(-((Y + 0.8) ** 2) / 0.05)
apparition_pattern += upper_berth
dt = 0.001
t_span = (0.0, 2.0)
steps = int((t_span[1] - t_span[0]) / dt)
for step in range(steps):
t = step * dt
if 0.5 <= t < 0.7:
P_ext = 8.0 * apparition_pattern
else:
P_ext = np.zeros((nx, ny))
observer1.step(dt, P_ext=P_ext)
observer2.step(dt, P_ext=P_ext)
final1 = observer1.E
final2 = observer2.E
correlation = np.corrcoef(final1.flatten(), final2.flatten())[0, 1]
print(f"Correlation between two observers' visual fields: {correlation:.3f}")
# Optional plot
fig, axes = plt.subplots(1, 2, figsize=(10, 5))
im1 = axes[0].imshow(final1, cmap="hot")
axes[0].set_title("Observer 1 (Mr. Wilmot)")
plt.colorbar(im1, ax=axes[0])
im2 = axes[1].imshow(final2, cmap="hot")
axes[1].set_title("Observer 2 (Mr. Tait)")
plt.colorbar(im2, ax=axes[1])
plt.suptitle("Wilmot crisis apparition – Dual perception")
plt.tight_layout()
plt.show()
return correlation # <-- return scalar metric (observer correlation)
if __name__ == "__main__":
run_wilmot()