# MTK & structural\_parameters

**URL:** <https://discourse.julialang.org/t/mtk-structural-parameters/115239>\
**Category:** Modelling & Simulations\
**Created:** [June 5, 2024, 3:46pm UTC](https://discourse.julialang.org/t/mtk-structural-parameters/115239 "2024-06-05T15:46:07Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![BLI](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bli/32/37206_2.png) [@BLI](https://discourse.julialang.org/u/BLI)\
**Post date:** [June 5, 2024, 3:46pm UTC](https://discourse.julialang.org/t/mtk-structural-parameters/115239/1 "2024-06-05T15:46:07Z")

</div>

I have a gas model where I want to compare two cases:

- using a fixed “compressibility factor” z
- computing z from an EoS [Equation of State]

The idea is to compare the dynamic behavior. So my idea is to add a `structural_parameters` block:

```julia
    @structural_parameters begin
        z_choice = :fixed
    end

```

thus with `z_choice` as `:fixed` by default. If I instead want to use a cubic EoS, set `z_choice=:cubic`.

I have a long list of equations…

```julia
@equations begin
    ... ~ ...
    z ~ ...
    ... ~ ...
end

```

**Question** : How do I switch between how I compute `z` in the _equations_? Is the correct way to do:

```julia
if z_choice == :fixed
    @equations begin
        ...~...
        z ~ 0.9
        ... ~ ...
    end
elseif z_choice == :cubic
    @equations begin
        ... ~ ...
        z ~ cubic(...)
        ... ~ ...
    end
end

```

[do I need to enclose the above in a `begin...end` block?]

**or** can I do the following (saving dramatically on the number of code lines):

```julia
@equations begin
    ... ~ ...
    if z_choice == :fixed
        z ~ 1.3
    elseif z_choice == :cubic
        z ~ cubic(...)
    end
    ... ~ ...
end
```

---

<div class="post-metadata">

**Author:** ![baggepinnen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/baggepinnen/32/693_2.png) [@baggepinnen](https://discourse.julialang.org/u/baggepinnen)\
**Post date:** [June 5, 2024, 4:20pm UTC](https://discourse.julialang.org/t/mtk-structural-parameters/115239/2 "2024-06-05T16:20:48Z")

</div>

You should be able to do the last one, have you tried?

---

<div class="post-metadata">

**Author:** ![BLI](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bli/32/37206_2.png) [@BLI](https://discourse.julialang.org/u/BLI)\
**Post date:** [June 5, 2024, 4:44pm UTC](https://discourse.julialang.org/t/mtk-structural-parameters/115239/3 "2024-06-05T16:44:13Z")

</div>

Haven’t tested yet… I feel rather uncertain about how macros work + have just upgraded to Julia 10.4 and reinstalled packages, so my laptop is running out of juice. Will test after la cena…

---

<div class="post-metadata">

**Author:** ![BLI](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bli/32/37206_2.png) [@BLI](https://discourse.julialang.org/u/BLI)\
**Post date:** [June 5, 2024, 7:00pm UTC](https://discourse.julialang.org/t/mtk-structural-parameters/115239/4 "2024-06-05T19:00:17Z")

</div>

Yupp. It worked…
