# Applying dynamic loads to given points in the structural dynamic analysis

**URL:** <https://fenicsproject.discourse.group/t/applying-dynamic-loads-to-given-points-in-the-structural-dynamic-analysis/12113>\
**Category:** dolfinx\
**Created:** [September 5, 2023, 8:48am UTC](https://fenicsproject.discourse.group/t/applying-dynamic-loads-to-given-points-in-the-structural-dynamic-analysis/12113 "2023-09-05T08:48:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kepler](https://avatars.discourse-cdn.com/v4/letter/k/71c47a/32.png) [@Kepler](https://fenicsproject.discourse.group/u/Kepler)\
**Post date:** [September 5, 2023, 8:48am UTC](https://fenicsproject.discourse.group/t/applying-dynamic-loads-to-given-points-in-the-structural-dynamic-analysis/12113/1 "2023-09-05T08:48:50Z")

</div>

Hi, I’m new on Fenics. Now I’m encountering a problem in the structural dynamic analysis.  
As for the loads are applied to several interior points (the coordinates are given) as below and are a discrete value at every timestep, they cannot be uniformly described by Expressions.

```auto
*Amplitude, Name=N1_X
          0.02, -0.000602584839, 0.04, -0.0973661804, 0.06, -2.63061237, 0.08, -34.7715683,
           0.1, -292.87326, 0.12, -1759.55915, 0.14, -8015.15675, 0.16, -28724.2546,
          0.18, -82932.8842, 0.2, -196220.825, 0.22, -387184.113, 0.24, -656762.817,
          0.26, -1019174.46, 0.28, -1597426.06, 0.3, -2720511.2, 0.32, -4893093.11,
          0.34, -8597781.18, 0.36, -14063301.1, 0.38, -21133379.0, 0.4, -29211088.2,
          0.42, -37278133.4, 0.44, -44185226.4, 0.46, -49219863.9, 0.48, -52382289.9,
           0.5, -53873630.5

```

I referred to the case here:[How can point loads be applied to the end of the cantilever beam?](https://fenicsproject.discourse.group/t/how-can-point-loads-be-applied-to-the-end-of-the-cantilever-beam/8253/2) But in this case the load is constant and the code is for dolfin rather than dolfinx.

Is there any similar cases for dolfinx that I can refer to?  
Can you provide any effective ideas? Thank you very much!

---

<div class="post-metadata">

**Author:** ![jkrokowski](https://avatars.discourse-cdn.com/v4/letter/j/0ea827/32.png) [@jkrokowski](https://fenicsproject.discourse.group/u/jkrokowski)\
**Post date:** [October 26, 2023, 6:45pm UTC](https://fenicsproject.discourse.group/t/applying-dynamic-loads-to-given-points-in-the-structural-dynamic-analysis/12113/2 "2023-10-26T18:45:41Z")

</div>

In legacy FEniCS there was a method called PointSource() that was used to do this. Unfortunately, PointSource() has not yet be reimplemented in FEniCSx.

However, you can implement point loads by simply modifying your RHS vector, provided your load is applied directly on a node. Here is some starter code that might help.

instead of the simplified:

```auto
from dolfinx.fem.petsc import LinearProblem

uh = Function(FXNSPACE)
problem = LinearProblem(a,L, u=uh, bcs=[bc1,bc2,....])
uh = self.problem.solve()

```

you would use something like:

```auto
from dolfinx.fem.petsc import (assemble_matrix, create_vector, assemble_vector, 
                               apply_lifting, set_bc, create_vector)
from petsc4py import PETSc 

A =assemble_matrix(form(a),bcs=[bc1,bc2,....])
A.assemble()

b = create_vector(form(
with b.localForm() as b_loc:
                    b_loc.set(0)
assemble_vector(b,form(L))

apply_lifting(b,[form(a)],bcs=[self.bcs])
b.ghostUpdate(addv=PETSc.InsertMode.ADD, mode=PETSc.ScatterMode.REVERSE)
set_bc(b,[bc1,bc2,....])

def locate_dofs(x):
    return *some np boolean based on spatial coords*

f_dofs = locate_dofs_geometrical(FXNSPACE,locate_dofs)
b.arrayp[f_dofs[0]] = f

uh = Function(FXNSPACE)
uvec = self.uh.vector
uvec.setUp()
ksp = PETSc.KSP().create()
ksp.setType(PETSc.KSP.Type.CG)
ksp.setTolerances(rtol=1e-15)
ksp.setOperators(self.A_mat)
ksp.solve(self.b,uvec)

```
