Enforce EP
This commit is contained in:
parent
66701bab38
commit
8d3cbe5f4d
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue