# Dirac delta implementation in gridap

**URL:** <https://discourse.julialang.org/t/dirac-delta-implementation-in-gridap/101144>\
**Category:** New to Julia\
**Tags:** question, package, gridap\
**Created:** [July 3, 2023, 9:20pm UTC](https://discourse.julialang.org/t/dirac-delta-implementation-in-gridap/101144 "2023-07-03T21:20:04Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mary](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mary/32/53139_2.png) [@mary](https://discourse.julialang.org/u/mary)\
**Post date:** [July 3, 2023, 9:20pm UTC](https://discourse.julialang.org/t/dirac-delta-implementation-in-gridap/101144/1 "2023-07-03T21:20:04Z")

</div>

Hi dear all, i want to use Dirac delta function in my domain not just at special point like x0. below is a example of this

```julia
function MatrixOf(fem_params)
    x0 = VectorValue(0,300) # Position of the field to be optimized
    δ = 1
    return assemble_matrix(fem_params.U, fem_params.V) do u, v
        ∫((x->(1/(2*π)*exp(-norm(x - x0)^2 / 2 / δ^2))) * (∇(u) ⋅ ∇(v)) )fem_params.dΩ_c
    end
end

```

and to be clear it finds the matrix around x0. however i want to assemble it for each node. i have derived the node coordinate by below line

```julia
co= VectorValue(Gridap.ReferenceFEs.get_node_coordinates(Ω))

```

however i cant make a loop for gridap to go through this vector and find o for each and then assemble it for all.  
thanks for any suggestion.

---

<div class="post-metadata">

**Author:** ![mary](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mary/32/53139_2.png) [@mary](https://discourse.julialang.org/u/mary)\
**Post date:** [July 3, 2023, 9:22pm UTC](https://discourse.julialang.org/t/dirac-delta-implementation-in-gridap/101144/2 "2023-07-03T21:22:06Z")

</div>

@stevengj Hi, I have read the issues that you have been submitted on Dirac delta. can i apply Dirac delta not in guassian form to solve my problem?

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [July 3, 2023, 9:54pm UTC](https://discourse.julialang.org/t/dirac-delta-implementation-in-gridap/101144/3 "2023-07-03T21:54:51Z")

</div>

I think you currently have to smooth out your delta function (e.g. as a Gaussian) in order to put it at an arbitrary point. This should be on the same order as other discretization errors if you make your smoothed delta have a diameter proportional to your mesh resolution.

---

<div class="post-metadata">

**Author:** ![mary](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mary/32/53139_2.png) [@mary](https://discourse.julialang.org/u/mary)\
**Post date:** [July 3, 2023, 10:02pm UTC](https://discourse.julialang.org/t/dirac-delta-implementation-in-gridap/101144/4 "2023-07-03T22:02:48Z")

</div>

thanks, so how can i make it to go through all points of domain not just one arbitrary point ? should i define for loop ?  
i did it as below but it is not working

```julia
 x0 = VectorValue(fem_params.co)
∫( (x->((1/(2*π))*exp(-norm(x-x0[i])^2 / (2 * δ^2)))) * (∇(u)⊙ ∇(v)) )fem_params.dΩ for i in (0:4805)

```
