ModelingToolkit.jl
ModelingToolkit.jl copied to clipboard
A switch variable in startup.jl? If not enabled, do not parse the code string `unit = u"V"` to avoid Unit buggs
Is your feature request related to a problem? Please describe.
Unit system is only auxiliary to modeling and solving, but useful. Many variables from Blocks have no Units, so it is very troublesome to balance the units when equation solving. Currently, Unit only have a display function before solving.
In addtion, there are still some Issues about the Unit System, which may be improved in the future when there is time. Is it necessary to have mtk provide a switch variable? If this variable is not enabled, the code string of Unit metadata like unit = u"V" will not be parsed to avoid unnecessary buggs like the issue #3247.
Describe the solution you’d like
Perhaps, the switch variable can be placed in .julia\config\startup.jl as a global variable, or some other user-settable way. startup.jl needs to be created manually.
Additional context
My temporary Unit solution like unit = u("Resistance") had been described at the issue comment.
After I learned Julia macro and mtk, I would also like to contribute some code.
This would be for the standard library? I think it would make sense there.
To avoid the unit errors https://github.com/SciML/ModelingToolkit.jl/issues/3247#issuecomment-2774215354,
I temporarily commented out the body of the check_units function in unit_check.jl,
and canceled unit in the parse_variable_arg function in model_parsing.jl.
if haskey(metadata_with_exprs, VariableUnit)
delete!(metadata_with_exprs, VariableUnit)
end
It could be a Preferences.jl thing, though we should don't reexport it?