-
Notifications
You must be signed in to change notification settings - Fork 170
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
May I ask how to represent a system of differential equations? #2
Comments
Sure, you can solve it with a PINN. First ensure that the last layer of your NN contains 4 neurons (i.e., one for V,m,h,n). Please review this repository: https://github.com/alexpapados/Physics-Informed-Deep-Learning-Solid-and-Fluid-Mechanics/blob/main/Compressible%20Hydrodynamic%20Shock-Tube%20Problems%20(1-D%20Compressible%20Euler%20Equations)/Forward%20Problems%20W-PINNs-DE/Euler_Eq_Reverse_Sod_Shock_Tube_Problem.py Then, using automatic differentiation you can obtain each time derivative Set up your four PDEs as loss functions (remember they should be equal to zero). The total loss PDE would be the sum of your four PDEs: I hope it helps! |
Thank you very much for your help. |
Hello,My problem is described as followsWe will solve a simple ODE system: with the initial conditions The reference solution is here, where the parameters My code can't predict the parameters correctly, how can I modify the loss function so that the parameters can be predicted correctly?# General Loss Function
def loss_func(self):
y_pred = self.net_y(self.t)
v_nn, m_pred, h_pred, n_pred = y_pred[:, 0], y_pred[:, 1], y_pred[:, 2], y_pred[:, 3] # NN_{rho}, NN_{u}, NN_{p}
# Reshape data
m_pred = m_pred.reshape(len(m_pred), 1)
h_pred = h_pred.reshape(len(h_pred), 1)
n_pred = n_pred.reshape(len(n_pred), 1)
v_nn = v_nn.reshape(len(v_nn), 1)
v_pred = 10.0- (self.g1 * m_pred**3 * h_pred *(v_nn-50.0))-\
(self.g2 * n_pred**4 * (v_nn-77.0))-(self.g3 * (v_nn-54.387))
# Total Loss
loss = torch.mean((self.m - m_pred) ** 2) + torch.mean((self.h - h_pred) ** 2) + \
torch.mean((self.n - n_pred) ** 2) + torch.mean(((self.v - v_pred)) ** 2)
self.optimizer.zero_grad()
loss.backward()
self.iter += 1
# if self.iter%101==0:
# print("iter: ",self.iter)
print(
'Loss: %.3f, g1_PINNs: %.5f ,g2_PINNs: %.5f,g3_PINNs: %.5f ' %
(
loss.item(),
self.g1.item(),
self.g2.item(),
self.g3.item()
)
)
return loss
# Train network through minimization of loss function w/r to theta and gamma
def train(self, nIter):
self.dnn.train()
# Backward and optimize
self.optimizer.step(self.loss_func) My complete code is in this link https://github.com/squarefaceyao/pinn_inverse_pes/blob/main/HH_inverse__pytorch.py Thank you for your help. |
I want to ask if you think you can use PINN to solve this problem.
We will solve a simple ODE system:
May I ask how to represent a system of differential equations?
with the initial conditions
$$V(0) = -65, \quad m(0) = 0.05 , \quad h(0) = 0.6 , \quad n(0) = 0.32 $$
The reference solution is here, where the parameters$G_{na},G_{k},G_{L}$ are gated variables and whose true values are 120, 36, and 0.3, respectivly.
The code below is the data description
The text was updated successfully, but these errors were encountered: