Skip to content

Commit

Permalink
continue improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
lehner committed Sep 22, 2024
1 parent 9588ed7 commit fe93700
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 19 deletions.
19 changes: 7 additions & 12 deletions lib/gpt/qcd/pseudofermion/action/exact_one_flavor.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,12 @@ def __init__(self, fermion, m1, m2, inverter):
M12_adj = M12.adj()
M11_adj = M11.adj()
super().__init__([M12, M11, M12_adj, M11_adj], inverter, fermion)
self.P12 = M12.propagator(inverter)
self.P11 = M11.propagator(inverter)
self.inv_M12_adj = inverter(M12_adj)
self.inv_M11_adj = inverter(M11_adj)

def matrix(self, fields):
M12, M11, M12_adj, M11_adj, U, phi = self._updated(fields)

P12 = self.P12
P11 = self.P11
P12 = M12.propagator(self.inverter)
P11 = M11.propagator(self.inverter)

m1 = self.m1
m2 = self.m2
Expand Down Expand Up @@ -122,15 +118,14 @@ def gradient(self, fields, dfields):

frc = self._allocate_force(U)

inv_M12_adj = self.inverter(M12_adj)
inv_M11_adj = self.inverter(M11_adj)

m1 = self.m1
m2 = self.m2

w_plus = g(
self.inv_M12_adj * M12.R * g.gamma[5] * M12.ImportUnphysicalFermion * Pplus * phi
)
w_minus = g(
self.inv_M11_adj * M11.R * g.gamma[5] * M11.ImportUnphysicalFermion * Pminus * phi
)
w_plus = g(inv_M12_adj * M12.R * g.gamma[5] * M12.ImportUnphysicalFermion * Pplus * phi)
w_minus = g(inv_M11_adj * M11.R * g.gamma[5] * M11.ImportUnphysicalFermion * Pminus * phi)

w2_plus = g(g.gamma[5] * M12.R * M12.Dminus.adj() * w_plus)
w3_plus = g(Pplus * phi)
Expand Down
13 changes: 6 additions & 7 deletions lib/gpt/qcd/pseudofermion/action/two_flavor.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def gradient(self, fields, dfields):
dS.append(g.qcd.gauge.project.traceless_hermitian(frc[mu]))
else:
dS.append(None)
#raise Exception("not implemented")
# raise Exception("not implemented")
return dS


Expand Down Expand Up @@ -137,16 +137,15 @@ def __init__(self, M, inverter, operator):
assert len(M) == 2
super().__init__(M, inverter, operator)
M1, M2 = M
self.inv_MMdag_M1 = inverter(operator.MMdag(M1))
self.inv_MMdag_M2 = inverter(operator.MMdag(M2))

def __call__(self, fields):
M1, M2, U, phi = self._updated(fields)

psi = g.lattice(phi)
psi @= self.operator.M(M2) * phi
chi = g.lattice(phi)
chi @= self.inv_MMdag_M1 * psi

chi @= self.inverter(self.operator.MMdag(M1)) * psi
return g.inner_product(psi, chi).real

def draw(self, fields, rng):
Expand All @@ -158,7 +157,7 @@ def draw(self, fields, rng):
# phi^dag M2dag (M1 M1dag)^-1 M2 phi
# eta = M1^-1 M2 phi
chi = g.lattice(phi)
chi @= self.inv_MMdag_M2 * self.operator.M(M1) * eta
chi @= self.inverter(self.operator.MMdag(M2)) * self.operator.M(M1) * eta
phi @= self.operator.Mdag(M2) * chi
return g.norm2(eta)

Expand All @@ -170,7 +169,7 @@ def gradient(self, fields, dfields):
psi = g.lattice(phi)
psi @= self.operator.M(M2) * phi
chi = g.lattice(phi)
chi @= self.inv_MMdag_M1 * psi
chi @= self.inverter(self.operator.MMdag(M1)) * psi
psi @= self.operator.Mdag(M1) * chi

self._accumulate(frc, self.operator.Mderiv(M2)(chi, phi), +1)
Expand All @@ -184,7 +183,7 @@ def gradient(self, fields, dfields):
if mu < len(fields) - 1:
dS.append(g.qcd.gauge.project.traceless_hermitian(frc[mu]))
else:
#raise Exception("not implemented")
# raise Exception("not implemented")
dS.append(None)
return dS

Expand Down

0 comments on commit fe93700

Please sign in to comment.