# A error of composition

**URL:** <https://community.geodynamics.org/t/a-error-of-composition/3517>\
**Category:** ASPECT\
**Created:** [June 21, 2024, 7:01am UTC](https://community.geodynamics.org/t/a-error-of-composition/3517 "2024-06-21T07:01:36Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![HangWu](https://avatars.discourse-cdn.com/v4/letter/h/f17d59/32.png) [@HangWu](https://community.geodynamics.org/u/HangWu)\
**Post date:** [June 21, 2024, 7:01am UTC](https://community.geodynamics.org/t/a-error-of-composition/3517/1 "2024-06-21T07:01:36Z")

</div>

Hi there，  
Recently I wanted to construct a two-dimensional model to study lower crustal flow deformation in eastern Tibet. I divided the model into eight parts: SC\_uc, Tibet\_uc, Tibet\_lc, SC\_lc, Tibet\_lm, SC\_lm, Tibet\_as, SC\_as.  
When I run it, I get the following error：

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/geodynamics/original/2X/7/79c83113a861270454ef8b0398730b3fce21208a.png)  
I have checked my initial composition and temperature and the parameters given in the viscoplastic material and there doesn’t seem to be a mismatch error, how do I fix this.  
My .prm file is as follows：  
[Eastern\_Tibet.prm](https://community.geodynamics.org/uploads/short-url/i1JggR2mO2ZxdNS2Nh70xEbrsKp.prm) (8.5 KB)

All the best，  
HangWu

---

<div class="post-metadata">

**Author:** ![bobmyhill](https://yyz2.discourse-cdn.com/flex036/user_avatar/community.geodynamics.org/bobmyhill/32/38_2.png) [@bobmyhill](https://community.geodynamics.org/u/bobmyhill)\
**Post date:** [June 21, 2024, 8:35am UTC](https://community.geodynamics.org/t/a-error-of-composition/3517/2 "2024-06-21T08:35:44Z")

</div>

Dear HangWu,

The initial temperature function should have only one expression (temperature is a scalar field). You have provided 8 expressions (delimited by semicolons).

ASPECT expects a single expression for the initial temperature field. You should redesign your function so that the separate expressions are replaced by nested if statements. The syntax for an if statement is if(condition, true-expression, false-expression). Within the false-expression you can put another if statement.

You may also wish to look at lazy evaluation ([How to write Function expressions in parameter files — ASPECT 2.6.0-pre](https://aspect-documentation.readthedocs.io/en/latest/user/run-aspect/parameters-overview/muparser-format.html#lazy-expressions)) to speed up evaluation.

Best wishes,  
Bob

---

<div class="post-metadata">

**Author:** ![HangWu](https://avatars.discourse-cdn.com/v4/letter/h/f17d59/32.png) [@HangWu](https://community.geodynamics.org/u/HangWu)\
**Post date:** [June 21, 2024, 8:48am UTC](https://community.geodynamics.org/t/a-error-of-composition/3517/3 "2024-06-21T08:48:40Z")

</div>

Hi Bob，  
Thanks for your reply.  
Since I’m considering two different blocks with different thicknesses of their lithosphere, I’m trying to make it difficult to account for this through an equation, or maybe it’s more convenient through an Ascii file?  
best，  
HangWu

---

<div class="post-metadata">

**Author:** ![bobmyhill](https://yyz2.discourse-cdn.com/flex036/user_avatar/community.geodynamics.org/bobmyhill/32/38_2.png) [@bobmyhill](https://community.geodynamics.org/u/bobmyhill)\
**Post date:** [June 21, 2024, 9:23am UTC](https://community.geodynamics.org/t/a-error-of-composition/3517/4 "2024-06-21T09:23:52Z")

</div>

Dear HangWu,

Your expression is almost correct - it just doesn’t make any sense within normal geodynamics frameworks to make temperature a vector field.

Perhaps an ASCII file is more convenient for you, but I think for such a simple temperature structure it’s also fine to have nested if statements.

If you want to test your expression, you might consider trying out [GitHub - bobmyhill/pymuparser: Python binding for MuParser library.](https://github.com/bobmyhill/pymuparser/), using the ScalarExpression class (see, for example, [pymuparser/examples/example\_scalar.py at main · bobmyhill/pymuparser · GitHub](https://github.com/bobmyhill/pymuparser/blob/main/examples/example_scalar.py)).

Best wishes,  
Bob
