Hi Eric!
The only variables that can be used for sensitivity analysis are those that the solver uses as states. You can influence how the solver selects states with the stateSelect attribute.
For example, in the following model:
model TestStates
Real x(start = 1);
parameter Real k=1;
output Real y(stateSelect=StateSelect.always);
equation
x*k=y;
der(x)=1;
end TestStates;
y is forced to be used as a a state.
So the following code will bring up y's sensitivity to k:`
WSMPlot[WSMSimulateSensitivity[
"TestStates", {0, 10}, {"k"}], {{"y", "k", 0.1}}]
The stateSelect attribute can take on the following values: StateSelect.never, StateSelect.avoid, StateSelect.default, StateSelect.prefer, StateSelect.always.
The difference between prefer and always is that in both cases the solver will prefer choosing the variable as a state, but if StateSelect.always is set, it will throw an error if it is unable to use the variable as a state. The same, but inverse is true for avoid and never.