Hi Açelya,

Thanks for posting this to the forum.

My thoughts below on what I think the issue is.

To start, please note the following:

- I used the “preformatted text” (</> icon symbol) option to preserve the formatting in the prm snippets below.
- I only included the x-velocity component for the function and added a
`\`

to be consistent with what is required in the ASPECT prm files.
- I used spaces to align starting and closing brackets (and the corresponding contents) of each conditional statement. I find this practice makes these expressions significantly easier to debug!

Here is the original function expression, updated with the methodology outlined above:

```
if ( t<50e6, \
( if ( x<1650e3 && z<=440.e3, -(0.25)/cm, \
if ( x<1650e3 && z>=440.e3, 0.5/cm, \
if ( x>1650e3 && z<=440.e3, (0.25)/cm, \
if ( x>1650e3 && z>=440.e3, -0.5/cm, 0) \
) \
) \
) \
); \
```

At first, glance, my first thought is that this expression should produce a runtime error, as their is no entry for what happens when `t>=50e6`

at the end.

For example, if you want the x-velocity to be 0 after `t>=50e6`

, then you would add `), 0 \`

and the second to last line:

```
if ( t<50e6, \
( if ( x<1650e3 && z<=440.e3, -(0.25)/cm, \
if ( x<1650e3 && z>=440.e3, 0.5/cm, \
if ( x>1650e3 && z<=440.e3, (0.25)/cm, \
if ( x>1650e3 && z>=440.e3, -0.5/cm, 0) \
) \
) \
), 0 \
); \
```

Note that I have not tested the above code, so there still may be some errors.

One strategy I use when writing and testing/debugging complex functions is to make other parts of the model very simple (1 nonlinear iteration, constant viscosity, only run two time steps, etc, etc) and a start with a simple function like:

```
if ( t<50e6, \
( if ( x<1650e3 , -(0.25)/cm, -0.5/cm), \
0 \
)
```

and from there then keep adding complexity to the function and testing at each step to ensure the boundary conditions are giving the correct output.

I hope this helps and let us know if you have any further questions.

Cheers,

John