# How to apply a coordinate-dependent traction force in the boundary normal direction

**URL:** <https://fenicsproject.discourse.group/t/how-to-apply-a-coordinate-dependent-traction-force-in-the-boundary-normal-direction/17228>\
**Category:** dolfinx\
**Created:** [March 17, 2025, 12:33am UTC](https://fenicsproject.discourse.group/t/how-to-apply-a-coordinate-dependent-traction-force-in-the-boundary-normal-direction/17228 "2025-03-17T00:33:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![French\_fries](https://avatars.discourse-cdn.com/v4/letter/f/71c47a/32.png) [@French\_fries](https://fenicsproject.discourse.group/u/French_fries)\
**Post date:** [March 17, 2025, 12:33am UTC](https://fenicsproject.discourse.group/t/how-to-apply-a-coordinate-dependent-traction-force-in-the-boundary-normal-direction/17228/1 "2025-03-17T00:33:31Z")

</div>

The following code represents a linear elasticity problem with a uniform traction force applied in the normal direction on boundary 1. How should I modify this code if I want to set the traction force as a function of the z-coordinate (e.g., T = z + 1)?

```auto
T = Constant(mesh, 10)    
n = FacetNormal(mesh)

dU = TrialFunction(VU)
U_ = TestFunction(VU)
ds = Measure('ds', domain=mesh, subdomain_data=facet_markers)
Wint = inner(sigma(dU, Delta_T), eps(U_)) * dx
aM = lhs(Wint)
LM = rhs(Wint) + dot(T * n, U_) * ds(1)

```

---

<div class="post-metadata">

**Author:** ![dokken](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/dokken/32/1560_2.png) [@dokken](https://fenicsproject.discourse.group/u/dokken)\
**Post date:** [March 17, 2025, 5:08am UTC](https://fenicsproject.discourse.group/t/how-to-apply-a-coordinate-dependent-traction-force-in-the-boundary-normal-direction/17228/2 "2025-03-17T05:08:24Z")

</div>

Use

```auto
x,y,z = ufl.SpatialCoordinate(mesh)
T = fem.Constant(mesh, 1.) + z

```

---

<div class="post-metadata">

**Author:** ![French\_fries](https://avatars.discourse-cdn.com/v4/letter/f/71c47a/32.png) [@French\_fries](https://fenicsproject.discourse.group/u/French_fries)\
**Post date:** [March 18, 2025, 12:08am UTC](https://fenicsproject.discourse.group/t/how-to-apply-a-coordinate-dependent-traction-force-in-the-boundary-normal-direction/17228/3 "2025-03-18T00:08:12Z")

</div>

Thank you for your prompt reply.
