# How to write speed expressions

**URL:** <https://community.geodynamics.org/t/how-to-write-speed-expressions/4239>\
**Category:** ASPECT\
**Created:** [August 5, 2025, 2:52pm UTC](https://community.geodynamics.org/t/how-to-write-speed-expressions/4239 "2025-08-05T14:52:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sxj](https://avatars.discourse-cdn.com/v4/letter/s/9dc877/32.png) [@sxj](https://community.geodynamics.org/u/sxj)\
**Post date:** [August 5, 2025, 2:52pm UTC](https://community.geodynamics.org/t/how-to-write-speed-expressions/4239/1 "2025-08-05T14:52:27Z")

</div>

Hello,

I designed a mid-ocean ridge model. The coordinate of the ridge axis is 0. At the ridge axis itself, the velocity is zero, and at a distance of 10 kilometers from the ridge. axis or more, the rigid plate uniformly moves away from the ridge with a constant speed, and close to the ridge we interpolate between these two conditions. The interpolation formula is (1 - ((x/x0 - 1) \* (x/x0 - 1))) \* u0. The expression I wrote is as follows, but it keeps giving errors and I can’t figure out the reason. The screenshot of the error I mentioned is also provided below. Please help me. Thank you all.

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/geodynamics/original/2X/3/35f15e48f88576c8d58da0f288b6b365bd4816f4.png)

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/geodynamics/original/2X/0/0d57dabde3e966ca63b5c1852fde02b96d13dd3f.png)

---

<div class="post-metadata">

**Author:** ![daniel.douglas](https://yyz2.discourse-cdn.com/flex036/user_avatar/community.geodynamics.org/daniel.douglas/32/2126_2.png) [@daniel.douglas](https://community.geodynamics.org/u/daniel.douglas)\
**Post date:** [August 5, 2025, 6:08pm UTC](https://community.geodynamics.org/t/how-to-write-speed-expressions/4239/2 "2025-08-05T18:08:47Z")

</div>

Hi sxj,

The error that you are receiving is because the `Function` model in `Boundary velocity` expects to receive two values in 2-D models (vx, vy), and three values if 3-D models (vx, vy, vz). The way ASPECT parses these different components is by looking for semicolons in the `Function expression`, so in 2-D this would look something like:

```auto

set Function expression = vx; vy

```

and you can see that in your case you have 4 different statements, which is why ASPECT is saying that the number of components (2, in a 2D model) does not equal the number of expressions (4, in you function expression). To achieve what you want in your model, you would need to do something like:

```auto
set Function expression = if(x>x0, vx, if(x < x0 && x > 0, linear_function), 0); vy

```

Where `vx` is the x velocity and `vy` is the y velocity. I hope this helps!

Cheers,

Daniel
