def _co_eqn(self, t, sol_adj): """ compute residuals LHS """ x_adj, y_adj = sol_adj[:, 0].reshape(-1, 1), sol_adj[:, 1].reshape(-1, 1) eqn1 = diff(x_adj, t) + t * y_adj eqn2 = diff(y_adj, t) - t * x_adj return eqn1, eqn2
def adjust(self, x, t): """ perform initial value adjustment """ x_adj = self.x0 + (1 - torch.exp(-t)) * self.dx_dt0 + ( (1 - torch.exp(-t))**2) * x dx = diff(x_adj, t) d2x = diff(dx, t) return {'pred': x_adj, 'dx': dx, 'd2x': d2x}
def _sir_eqn(self, t, x_adj): S_adj, I_adj, R_adj = x_adj[:, 0], x_adj[:, 1], x_adj[:, 2] S_adj, I_adj, R_adj = S_adj.reshape(-1, 1), I_adj.reshape( -1, 1), R_adj.reshape(-1, 1) eqn1 = diff(S_adj, t) + self.beta * I_adj * S_adj / self.N eqn2 = diff(I_adj, t) - (self.beta * I_adj * S_adj / self.N) + self.gamma * I_adj eqn3 = diff(R_adj, t) - self.gamma * I_adj return eqn1, eqn2, eqn3
def adjust(self, y, u): a = self.bc[0] b = (self.bc[1] - self.bc[0]) * (y - self.ymin) c = self.ymax - self.ymin d = (y - self.ymin) * (y - self.ymax) * u u_adj = a + b / c + d du = diff(u_adj, y) dre = diff(self._reynolds_stress(y, du), y) d2u = diff(du, y) return {'pred': u_adj, 'dre': dre, 'd2u': d2u}
def _poisson_eqn(self, u, x, y): return diff(u, x, order=2) + diff(u, y, order=2) - 2 * x * (y - 1) * ( y - 2 * x + x * y + 2) * torch.exp(x - y)
def adjust(self, x, t): """ perform initial value adjustment """ x_adj = self.x0 + (1 - torch.exp(-t)) * x dx_dt = diff(x_adj, t) return {'pred': x_adj, 'dx': dx_dt}