-
Notifications
You must be signed in to change notification settings - Fork 42
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
Enable sensitivity analysis #372
base: main
Are you sure you want to change the base?
Conversation
An open question is coming up with a set of rules for determining what is a parameter and what is not? For example, non Float values (ie Flags) are not considered parameters. Some saturation values are also not passed as parameters. The only downside is that those values cannot be used in sensitivity analysis. |
Performance Results
ResidualModel and MassMatrixModel performance results should be compared between versions and not between models due to the execution order of the tests |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #372 +/- ##
==========================================
- Coverage 87.56% 87.13% -0.43%
==========================================
Files 65 66 +1
Lines 9156 8958 -198
==========================================
- Hits 8017 7806 -211
- Misses 1139 1152 +13
Flags with carried forward coverage won't be shown. Click here to find out more.
|
for entry in device_param_pairs | ||
if isa(entry, Tuple) | ||
label = join((entry[1], "params", entry[2:end]...), ".") | ||
else |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
else | |
else |
label = join((entry[1], "params", entry[2:end]...), ".") | ||
else | ||
label = entry | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
end | |
end |
|
||
#Dummy function that is overloaded in PowerSimulationsDynamicsSurrogates. | ||
#Eventually transition to EnzymeAdjoint() and remove Zygote altogether: https://github.com/SciML/OrdinaryDiffEq.jl/pull/2282 | ||
function _non_mutating_initialization_of_ml_surrogates(x0, p_new, sim_inputs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
function _non_mutating_initialization_of_ml_surrogates(x0, p_new, sim_inputs) | |
function _non_mutating_initialization_of_ml_surrogates(x0, p_new, sim_inputs) |
#Eventually transition to EnzymeAdjoint() and remove Zygote altogether: https://github.com/SciML/OrdinaryDiffEq.jl/pull/2282 | ||
function _non_mutating_initialization_of_ml_surrogates(x0, p_new, sim_inputs) | ||
return x0, p_new | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
end | |
end |
#_initialize_powerflow_and_devices!(x0, inputs, sys) | ||
elseif init_level == DEVICES_ONLY | ||
@warn "Reinitializing of most devices not supported with Zygote" | ||
x0, p_new = _non_mutating_initialization_of_ml_surrogates(x0, p_new, sim_inputs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
x0, p_new = _non_mutating_initialization_of_ml_surrogates(x0, p_new, sim_inputs) | |
x0, p_new = | |
_non_mutating_initialization_of_ml_surrogates(x0, p_new, sim_inputs) |
p_state, | ||
) | ||
#GET GROUND TRUTH DATA | ||
execute!(sim, MethodOfSteps(Rodas5()); abstol = 1e-6, reltol = 1e-6, dtmax = 0.05, saveat = 0.05) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
execute!(sim, MethodOfSteps(Rodas5()); abstol = 1e-6, reltol = 1e-6, dtmax = 0.05, saveat = 0.05) | |
execute!( | |
sim, | |
MethodOfSteps(Rodas5()); | |
abstol = 1e-6, | |
reltol = 1e-6, | |
dtmax = 0.05, | |
saveat = 0.05, | |
) |
sim, | ||
[("generator-102-1", :Shaft, :H)], | ||
[("generator-102-1", :δ)], | ||
MethodOfSteps(Rodas5(autodiff=false)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
MethodOfSteps(Rodas5(autodiff=false)), | |
MethodOfSteps(Rodas5(; autodiff = false)), |
f_zygote_forward([3.15], [p_state], δ_gt, []) | ||
#@test f_grad(p, [p_state], δ_gt) == | ||
# Zygote.gradient(p -> f_zygote_forward(p, [p_state], δ_gt), p)[1] | ||
@test Zygote.gradient(p -> f_zygote_forward(p, [p_state], δ_gt, []), p)[1][1] == -10.336102683050685 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
@test Zygote.gradient(p -> f_zygote_forward(p, [p_state], δ_gt, []), p)[1][1] == -10.336102683050685 | |
@test Zygote.gradient(p -> f_zygote_forward(p, [p_state], δ_gt, []), p)[1][1] == | |
-10.336102683050685 |
sim, | ||
[("generator-102-1", :Shaft, :H)], | ||
[("generator-102-1", :δ)], | ||
MethodOfSteps(Rodas5(autodiff=false)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
MethodOfSteps(Rodas5(autodiff=false)), | |
MethodOfSteps(Rodas5(; autodiff = false)), |
saveat = 0.05, | ||
) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
My goal is to make the building of a simulation and the solution differentiable. This will enable sensitivity analysis of the output of a dynamic simulation wrt some parameters of the system model. The first commit addresses the first step which is to build out the capability of passing and handling parameters as a flat vector (similar to the states).