Hello
I am new to julia coming from a python / mathematica background for pde solving. For simple testing I was trying a simpler version of black scholes equation. 0 drift (rates / dividends 0)
so it’s just the 2 term equation => partial derivative with respect to t and partial derivative with respect to s
eq = Dt(v(s,t)) + sigmasigma0.50ss*Ds2(v(s,t))~ 0
#####Code is as follows
using NeuralPDE, Flux, ModelingToolkit, GalacticOptim, Optim, DiffEqFlux
using Plots
@parameters s, t
@variables v(…)
@derivatives Dt’~t
@derivatives Ds2’'~s
sigma=0.20
eq = Dt(v(s,t)) + sigmasigma0.50ss*Ds2(v(s,t))~ 0
bcs = [v(s,1.0) ~ max(0.0,s-100.0),
v(0,t) ~ 0.0,Ds2(v(200,t))~0.0]
Space and time domains
domains = [s ∈ IntervalDomain(0.0,200.0), t ∈ IntervalDomain(0.0,1.0)]
Discretization
ds = 1; dt = 0.05
Neural network
chain = FastChain(FastDense(2,12,Flux.σ),FastDense(12,12,Flux.σ),FastDense(12,1))
discretization = PhysicsInformedNN(chain,
strategy = GridTraining(dx = [ds,dt]))
pde_system = PDESystem(eq,bcs,domains,[s,t],[v])
prob = discretize(pde_system,discretization)
opt = Optim.BFGS()
res = GalacticOptim.solve(prob,opt; cb = cb, maxiters=100)
phi = discretization.phi
#########
I think there is some issue with boundary conditions coz loss funcrtion is converging very slowly
Current loss is: 1360.7984022447545
Current loss is: 918.0802461010368
Current loss is: 910.7336935735061
Current loss is: 880.8667819607933
Current loss is: 876.3691892716076
Current loss is: 832.1532920935738
Current loss is: 831.3017231355975
***output
This is a very newbie question but i couldn’t find anything similar in the forums.
My boundary conditions are
bcs = [v(s,1.0) ~ max(0.0,s-100.0),
v(0,t) ~ 0.0,Ds2(v(200,t))~0.0]
=> 1. At expiry (1.0) option price = max (0.0, s-100.0)
=> 2. At 0 spot price the option price is 0, no matter that “t” remaining
=> 3. At higher boundary values for spot (200) the second derivative is 0 (function has no gamma)