This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

adding random noise with mean 0 and standard deviation s to the solution of 3D stakes problem

0 votes

Dear all

How I can add random noise with mean 0 and standard deviation s
to the solution u of 3D Stokes problem.

Thanks

asked Jul 29, 2016 by meftahi FEniCS Novice (300 points)

Adding stochastic coefficients to a PDE is non-trivial. Could you possibly elaborate on precisely what you're trying to achieve in terms of using FEniCS?

I want to solve the stokes problem to get a solution u for a fixed 3D shape. Then I want to perturb the data u by Gaussian noise to use it as a synthetic data to solve an inverse problem.

1 Answer

0 votes

If u is your vector you can do

N = u.vector.size()
u.vector()[:] = numpy.random.random(N)

Be aware that the mean will then be 0 in l1 rather than L1.
If you want it to be zero in L1 you would do something
like

c = assemble(u*dx)
u.vector()[:] -= c

answered Jul 31, 2016 by Kent-Andre Mardal FEniCS Expert (14,380 points)
...