Open tanmay2798 opened 8 months ago
The solution bundle method is used in this file - https://github.com/Isaac-Somerville/Neural-Networks-for-Solving-Differential-Equations/blob/main/ThreeBodyProblem/threeBodyOriginalMethod.py ?
Yes. The other files in the ThreeBodyProblem folder use this method as well, but also include curriculum learning
Okay, also can you tell me if I use spring mass system where there are double derivatives, according to your naming system, would it be like. x = trialSolution(x0, xOut, t) dxTrial = dTrialSolution(xOut, dxOut, t) d2xTrial = dTrialSolution(, d2xOut, t) What should be in place of ?
should it be the value I get if I pass xOut through the network?
For second derivatives, you would require another function, d2TrialSolution, that uses the analytic expression for the second derivative of trialSolution. It would look something like this:
def d2TrialSolution(varOut, dVarOut, d2VarOut, t): """ Second derivative w.r.t. t of trial solution for a given variable varOut at times t with initial values varInitial
Arguments:
varOut (tensor of shape (batchSize,1)) -- network output for variable at times t
dVarOut (tensor of shape (batchSize,1)) -- derivative of network output for variable w.r.t. t at times t
d2VarOut (tensor of shape (batchSize,1)) -- second derivative of network output for variable w.r.t. t at times t
t (tensor of shape (batchSize,1)) -- times at which variable is evaluated
Returns:
d2trialSoln (tensor of shape (batchSize,1)) -- second derivative of trial solution for given variable at
times t with initial values varInitial"""
# d2TrialSoln = (torch.exp(-t)) * dVarOut + ((1 - torch.exp(-t)) * d2VarOut) - torch.exp(-t) * varOut + torch.exp(-t) * dVarOut
d2TrialSoln = ((1 - torch.exp(-t)) * d2VarOut) + (torch.exp(-t) * (2 * d2VarOut - varOut))
return d2TrialSoln
In the train function you would be required to evaluate d2xOut in the same was dxOut was calculated: d2xOut = grad(dxOut,t,torch.ones_like(dxOut),retain_graph=True, create_graph=True)[0]
Problems 5, 7 and 8 have more examples of doing this for second derivatives, as well as calculating mixed partial derivatives using autograd.
Hope this helps!
@Isaac-Somerville https://github.com/Isaac-Somerville/Neural-Networks-for-Solving-Differential-Equations/blob/main/LagarisProblems/prob5.py
Is this and prob7 and prob8 in LagarisProblems folder are using solution bundle?
No but the methodology is the same regarding calculating derivatives of the trial solution
On Mon, 4 Mar 2024, 21:46 tanmay2798, @.***> wrote:
Is this and prob7 and prob8 in LagarisProblems folder are using solution bundle?
— Reply to this email directly, view it on GitHub https://github.com/Isaac-Somerville/Neural-Networks-for-Solving-Differential-Equations/issues/3#issuecomment-1977516833, or unsubscribe https://github.com/notifications/unsubscribe-auth/AUWODNAVFUTNGWITY476TFDYWTTS7AVCNFSM6AAAAABEFXILZWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNZXGUYTMOBTGM . You are receiving this because you commented.Message ID: <Isaac-Somerville/Neural-Networks-for-Solving-Differential-Equations/issues/3/1977516833 @github.com>
Okay, and should it be d2TrialSoln = ((1 - torch.exp(-t)) d2VarOut) + (torch.exp(-t) (2 * dVarOut - varOut))
Yes that's right
@Isaac-Somerville adam.txt I modified your code to work for spring mass dampener system (md2x/dt2 + bdx/dt + k(x-L)=0). But, for me it doesn't give promising results. Can you suggest what changes I need to make?
The solution bundle method is used in this file - https://github.com/Isaac-Somerville/Neural-Networks-for-Solving-Differential-Equations/blob/main/ThreeBodyProblem/threeBodyOriginalMethod.py ?