From 8d3cbe5f4dffa077fabb72781ed95ad2bc925d0f Mon Sep 17 00:00:00 2001 From: Nuwan Yapa Date: Sun, 27 Apr 2025 21:32:27 -0400 Subject: [PATCH] Enforce EP --- calculations/PMM.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/calculations/PMM.py b/calculations/PMM.py index db5559d..0ca87db 100644 --- a/calculations/PMM.py +++ b/calculations/PMM.py @@ -9,6 +9,9 @@ df.loc[df['re_E'] < 0, 'im_E'] = 0 # set im_E = 0 for bound states (to avoid squ df['E'] = df['re_E'] + 1j * df['im_E'] df['k'] = np.sqrt(df['E']) +c0 = df[df['E'] == 0]['c'].values[0] +df['c'] = df['c'] - c0 # shift c to set c=0 at the exceptional point + train_data = df[df['re_E'] < 0] target_data = df[df['re_E'] > 0] @@ -25,6 +28,14 @@ H0 = (H0 + torch.transpose(H0, 0, 1)).requires_grad_() # symmetric H1 = torch.randn(N, N, dtype=torch.complex128) H1 = (H1 + torch.transpose(H1, 0, 1)).requires_grad_() # symmetric +def enforce_ep(): # enforce exceptional point at c=0 + with torch.no_grad(): + H0[0:2, :] = 0 + H0[:, 0:2] = 0 + H0[0, 1] = 1 + +enforce_ep() + #%% # training @@ -60,6 +71,7 @@ for epoch in range(epochs): with torch.no_grad(): H0 -= lr * H0.grad H1 -= lr * H1.grad + enforce_ep() # %% # evaluate for all points