Hi!
I want to add a source term with white gaussian noise in a PDE with is similar to the heat equation:
To do so, I’ve tried to add a term f to the equation
f = Expression(‘C++expression for random number generated with a normal distribution of mean m and standard deviation s’, degree=1)
But I can’t find the expression I should use…
My entire code is here:
from __future__ import print_function
from fenics import *
import numpy as np
import matplotlib.pyplot as plt
T = 2 # temps total
num_steps = 20 # nombre de pas de temps
dt = T / num_steps # intervalle de temps
nx = ny = 500
mesh = UnitSquareMesh(nx,ny)
V = FunctionSpace(mesh, 'P', 1)
h_D = Expression('0', degree=2)
def boundary(x, on_boundary):
return on_boundary
bc = DirichletBC(V, h_D, boundary)
h_n = interpolate(h_D, V)
h = TrialFunction(V)
v = TestFunction(V)
f = Expression('**the expression I'm looking for**', degree=1)
F = h*v*dx + dt*dot(grad(h), grad(v))*dx - (h_n + dt*f)*v*dx
a, L = lhs(F), rhs(F)
h = Function(V)
t = 0
for n in range(num_steps):
t += dt
h_D.t = t
solve(a == L, h)
plot(h)
h_n.assign(h)
Am I trying to do it the right way? Should I had the noise term another way?