NeuralPDE.jl icon indicating copy to clipboard operation
NeuralPDE.jl copied to clipboard

Cover parser by tests

Open KirillZubov opened this issue 2 years ago • 0 comments

create a bunch of tests covering the parser to keep track of that the symbolic part is working correctly MWE

@parameters x
@variables u(..)

Dx = Differential(x)
eq = Dx(u(x)) ~ 0.
bcs = [u(0.) ~ u(0.)]
domains = [x ∈ Interval(0.0,1.0)]
chain = FastChain((x,p) -> x.^2)

chain([1],Float32[])
strategy_ = NeuralPDE.GridTraining(0.1)
discretization = NeuralPDE.PhysicsInformedNN(chain,strategy_)
pde_system = PDESystem(eq,bcs,domains,[x],[u])
prob = NeuralPDE.discretize(pde_system,discretization)

train_data =prob.f.f.loss_function.pde_loss_function.pde_loss_functions.contents[1].train_set
inner_loss =prob.f.f.loss_function.pde_loss_function.pde_loss_functions.contents[1].loss_function

dudx(x) = @. 2*x
@test inner_loss(train_data, Float32[]) ≈ dudx(train_data) rtol = 0.001

KirillZubov avatar Aug 13 '21 14:08 KirillZubov