Open hpieper14 opened 2 years ago
@ChrisRackauckas Can I assign this to myself? Unless it makes more sense for someone else to do this fix, I would like to do it.
Yup assigned. Let me know if you run into any issues: I think this might be a hard one but I think you can do it.
I've been reading through the code to map out the necessary changes and I want to make sure I understand the big picture before I go in and start changing things.
We want to extend the discretization framework so that it can work with PDESystems that have splatted vector variables, i.e. pde_system = PDESystem(eq, bcs, domains, [x,y...], [u(x,y...)])
. It looks like to me that the changes for this need to occur in the files symbolic_utilities.jl and discretize.jl. Symbolic_utilities.jl is where the current error is being thrown and as suggested by name, has symbolic parsing helper functions and if discretize.jl needs to be modified, it will be in the process of constructing the PINNRepresentation
.
Does this seem right to you?
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
@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
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
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
returns the name of the entire array instead of the name of the particular entry. 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?
I thought an alternative approach would be to splat z but it errors
In: ModelingToolkit.getname.(pde_system2.indvars)
Out: ERROR: MethodError: no method matching getname(::Num, ::Num, ::Num)
Closest candidates are:
getname(::Any, ::Any) at ~/.julia/packages/Symbolics/sDAUx/src/variable.jl:364
getname(::Any) at ~/.julia/packages/Symbolics/sDAUx/src/variable.jl:364
@ChrisRackauckas let me know when you get a chance to look at this!
We want to extend the discretization framework so that it can work with PDESystems that have splatted vector variables, i.e. pde_system = PDESystem(eq, bcs, domains, [x,y...], [u(x,y...)]). It looks like to me that the changes for this need to occur in the files symbolic_utilities.jl and discretize.jl. Symbolic_utilities.jl is where the current error is being thrown and as suggested by name, has symbolic parsing helper functions and if discretize.jl needs to be modified, it will be in the process of constructing the PINNRepresentation.
Does this seem right to you?
That seems right. And I think to do that, the canonical form needs to switch to something that is shared between the two. Since it seems like there's issues with the names on the array variables, instead of checking by name (which is ill-advised anyways), it should probably just keep the symbolic value and do direct symbolic isequals
checks. So basically, getname
just shouldn't be used at all, and anything that's like getname(x) == getname(y)
should just be isequals(x,y)
.
I am trying to solve a PDE with variables [t, z1, …, zn]. Here’s my code:
This gives the error
@ChrisRackauckas says that going through the parser and expanding
z
is a possible fix.