Skip to content

Bye bye ₊, use var symbols with . #2798

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 12, 2024
Merged

Bye bye ₊, use var symbols with . #2798

merged 5 commits into from
Jun 12, 2024

Conversation

ChrisRackauckas
Copy link
Member

This is something that was iteratively chipped away at during the v9 changes. The last thing left here was the handling of FuncAffect, which needed to have a funky reindexer to handle the fact that u.resisitor.v is done in two getproperty calls, and so we have to lazily merge the symbols.

This is non-breaking because we've been very specific to not rely on any of the symbol names in v9 for a very good reason, and this is that reason. I'm sure someone out there did hardcode ₊ stuff against all recommendations though...

I need to fix the printing in SymbolicUtils.jl to really finalize this change.

This is something that was iteratively chipped away at during the v9 changes. The last thing left here was the handling of FuncAffect, which needed to have a funky reindexer to handle the fact that u.resisitor.v is done in two getproperty calls, and so we have to lazily merge the symbols.

This is non-breaking because we've been very specific to not rely on any of the symbol names in v9 for a very good reason, and this is that reason. I'm sure someone out there did hardcode ₊ stuff against all recommendations though...

I need to fix the printing in SymbolicUtils.jl to really finalize this change.
@ChrisRackauckas
Copy link
Member Author

julia> rc_model
Model rc_model with 1 equations
Unknowns (1):
  capacitor.v
Parameters (3):
  resistor.R [defaults to 2.0]
  capacitor.C [defaults to 1.0]

Incidence matrix:1×2 SparseArrays.SparseMatrixCSC{Num, Int64} with 2 stored entries:
 ×  ×

julia> equations(rc_model)
1-element Vector{Equation}:
 Differential(t)(capacitor.v) ~ capacitor.i / capacitor.C

julia> unknowns(rc_model)
1-element Vector{SymbolicUtils.BasicSymbolic{Real}}:
 capacitor.v

julia> parameters(rc_model)
3-element Vector{SymbolicUtils.BasicSymbolic{Real}}:
 resistor.R
 capacitor.C
 source.V

julia> observed(rc_model)
19-element Vector{Equation}:
 source.v ~ source.V
 capacitor.p.v ~ capacitor.v
 capacitor.n.v ~ -0.0
 ground.g.v ~ 0.0
 
 source.p.i ~ source.i
 capacitor.p.i ~ -capacitor.n.i
 source.n.i ~ -source.p.i

and plot naming is fixed

Screenshot 2024-06-12 094250

@isaacsas
Copy link
Member

isaacsas commented Jun 12, 2024

Instead of hard-coding this character would it make sense to have a ModelingToolkit.SEPERATOR_CHARACTOR or such global variable downstream libraries and MTK could reuse?

@ChrisRackauckas
Copy link
Member Author

I don't know if we can actually support that given how . ties into getproperty.

@ChrisRackauckas ChrisRackauckas merged commit ad60d02 into master Jun 12, 2024
19 of 26 checks passed
@ChrisRackauckas ChrisRackauckas deleted the lowerplus branch June 12, 2024 15:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants