# How to get the variable names of a PDESystem if using a symbolic array

**URL:** <https://discourse.julialang.org/t/how-to-get-the-variable-names-of-a-pdesystem-if-using-a-symbolic-array/84776>\
**Category:** Modelling & Simulations\
**Tags:** modelingtoolkit, symbolics\
**Created:** [July 25, 2022, 9:19pm UTC](https://discourse.julialang.org/t/how-to-get-the-variable-names-of-a-pdesystem-if-using-a-symbolic-array/84776 "2022-07-25T21:19:03Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![hpieper14](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hpieper14/32/37510_2.png) [@hpieper14](https://discourse.julialang.org/u/hpieper14)\
**Post date:** [July 25, 2022, 9:19pm UTC](https://discourse.julialang.org/t/how-to-get-the-variable-names-of-a-pdesystem-if-using-a-symbolic-array/84776/1 "2022-07-25T21:19:03Z")

</div>

I’m having a hard time understanding exactly how a PDESystem with independent array variables differs from a PDESystem initialized with other independent variables. For example, suppose I have the following two PDESystems

```julia
@parameters t z1 z2 z[1:2]
pde_system1 = PDESystem(eq, bcs, domains, [t, z1, z2], [u(t, z1, z2)])
pde_system2 = PDESystem(eqs, bcs, domains, [t, z...], [u(t, z...)]) 

```

I can look at the independent variables and I would get

```nohighlight
In: pde_system1.indvars
Out: Num[t, z1, z2] 

In: pde_system2.indvars 
Out: Num[t, z[1], z[2]]

```

and both of these have type `Vector{Num}`. However, when I call `ModelingToolkit.getname`, I get

```nohighlight
In: ModelingToolkit.getname(pde_system1.indvars) 
Out: [:t, :z1, :z2] 

In: ModelingToolkit.getname(pde_system2.indvars) 
Out: [:t, :z, :z] 

```

It seems to me that `getname` in the case of `pde_system2` returns the name of the entire array instead of the name of the particular entry. I have two questions about this. First, why is this happening? Naively, it seems like because `pde_system1.indvars` and `pde_system2.indvars` have the same type, `ModelingToolkit.getname` should return names for each entry of the vector in both cases.

My second question is about how to address this. Is there a way to unpack the independent variables of `pde_system2` so that `ModelingToolkit.getname` returns a vector of symbols where each symbol corresponds to the entry of the array variables?

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [July 26, 2022, 2:28am UTC](https://discourse.julialang.org/t/how-to-get-the-variable-names-of-a-pdesystem-if-using-a-symbolic-array/84776/2 "2022-07-26T02:28:40Z")

</div>

@YingboMa @shashi

---

<div class="post-metadata">

**Author:** ![YingboMa](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yingboma/32/2181_2.png) [@YingboMa](https://discourse.julialang.org/u/YingboMa)\
**Post date:** [July 26, 2022, 2:30am UTC](https://discourse.julialang.org/t/how-to-get-the-variable-names-of-a-pdesystem-if-using-a-symbolic-array/84776/3 "2022-07-26T02:30:13Z")

</div>

That’s the expected behavior so that you can do `sys.z[1]` while `sys.z1` won’t make sense and might cause name collision.

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [July 26, 2022, 2:34am UTC](https://discourse.julialang.org/t/how-to-get-the-variable-names-of-a-pdesystem-if-using-a-symbolic-array/84776/4 "2022-07-26T02:34:53Z")

</div>

Okay then, maybe it’s an X-Y problem. Why is this name required?

---

<div class="post-metadata">

**Author:** ![hpieper14](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hpieper14/32/37510_2.png) [@hpieper14](https://discourse.julialang.org/u/hpieper14)\
**Post date:** [July 26, 2022, 12:41pm UTC](https://discourse.julialang.org/t/how-to-get-the-variable-names-of-a-pdesystem-if-using-a-symbolic-array/84776/5 "2022-07-26T12:41:00Z")

</div>

I’m working on extending `NeuralPDE.jl` so that it works with a `PDESystem` having independent variables that are a symbolic array.

Right now, I’m looking in `symbolic_utilities.jl` and I’m trying to modify [this](https://github.com/SciML/NeuralPDE.jl/blob/9dfe1d9bc35a8fedc1cabb4cd7f3c54f3e43e1e9/src/symbolic_utilities.jl#L345) function to handle the case that the independent variables contain a symbolic array.

The issue is that the function `Symbolics.nameof` errors with symbolic arrays, but I was thinking I could circumvent this by unpacking `z`. Is there an easier way that I’m not seeing?

---

<div class="post-metadata">

**Author:** ![hpieper14](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hpieper14/32/37510_2.png) [@hpieper14](https://discourse.julialang.org/u/hpieper14)\
**Post date:** [July 26, 2022, 1:21pm UTC](https://discourse.julialang.org/t/how-to-get-the-variable-names-of-a-pdesystem-if-using-a-symbolic-array/84776/6 "2022-07-26T13:21:11Z")

</div>

That makes sense to me.

As a related question, if `vars` has type `Vector{Num}`, then `ModelingToolkit.getname(vars)` throws an error, which is to be expected. However, `ModelingToolkit.getname.(vars)` does not. What does the `.()` operator do?

I looked in the documentation and on discourse but I couldn’t find any information.

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [July 26, 2022, 1:28pm UTC](https://discourse.julialang.org/t/how-to-get-the-variable-names-of-a-pdesystem-if-using-a-symbolic-array/84776/7 "2022-07-26T13:28:48Z")

</div>

> [@hpieper14](#):
>
> What does the `.()` operator do?
> 
> I looked in the documentation and on discourse but I couldn’t find any information.

> **[Extensible broadcast fusion](https://julialang.org/blog/2018/05/extensible-broadcast-fusion/)**
>
> Extensible broadcast fusion | Julia version 0.7 brings with it an exciting new feature: the ability to customize broadcast...

---

<div class="post-metadata">

**Author:** ![hpieper14](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hpieper14/32/37510_2.png) [@hpieper14](https://discourse.julialang.org/u/hpieper14)\
**Post date:** [July 26, 2022, 8:40pm UTC](https://discourse.julialang.org/t/how-to-get-the-variable-names-of-a-pdesystem-if-using-a-symbolic-array/84776/8 "2022-07-26T20:40:36Z")

</div>

@ChrisRackauckas I need a little help thinking through how to do this. Could you please take a look at this [issue](https://github.com/SciML/NeuralPDE.jl/issues/574) on Github and let me know what you think?
