I am trying to simulate a heat transfer model with location-specific boundary conditions (each discrete volume element has its own Robin BC). I am using a Physics-Informed NN and have made a similar post regarding the same issue, recently.

The example I used there (reproduced here) worked fine because the variable ‘a’ was only defined and used in the same for-loop.

```
function foo(u)
a = u(t,x,θ)^2
return a
end
# Initial and boundary conditions
X = collect(range(-1, 1, step=0.1))
bcs = Vector{ModelingToolkit.Equation}(undef, length(U)+2)
for i in eachindex(X)
a = foo(u)
bcs[i] = u(0,X[i],θ) ~ -a*sin(X[i]*pi)
end
```

The problem is that my actual code would need many of these ‘a’ variables defined over several for-loops, but when I try this:

```
a = Variable(:a)(x) # unknown, depends on `x`
#-----------------------------------------------------------------------
for i in eachindex(X)
ind = X[i]
global a(ind) = foo(u, X[i], 0)
end
for i in eachindex(X)
ind = X[i]
bcs[i] = u(0,X[i],θ) ~ -a(ind)*sin(X[i]*pi)
end
```

I get this error in the second for-loop: `cannot define function a; it already has a value`

When I try without the `global`

, I get this error: `MethodError: objects of type Operation are not callable`

I don’t really know what’s going on. The documentation for variables doesn’t have much on how to manipulate them.