Commit 00a94327 authored by Niina Helistö's avatar Niina Helistö
Browse files

Fixing cyclic state bounding

parent 264e59ef
......@@ -87,7 +87,8 @@ Sets
tt_forecast(t) "Temporary subset for time steps used for forecast updating during solve loop"
mf(mType, f) "Forecasts present in the models"
ms(mType, s) "Samples present in the models"
mstStart(mType, s, t) "Start point of samples"
mst_start(mType, s, t) "Start point of samples"
mst_end(mType, s, t) "Last point of samples"
ft(f, t) "Combination of forecasts and t:s in the current solve"
ft_realized(f, t) "Realized ft"
ft_realizedNoReset(f, t) "Full set of realized ft, facilitates calculation of results"
......
......@@ -1331,7 +1331,6 @@ q_boundStateMaxDiff(gnn_boundState(grid, node, node_), mft(m, f, t)) ..
* --- Cyclic Boundary Conditions ----------------------------------------------
q_boundCyclic(gn_state(grid, node), ms(m, s), s_)${ ms(m, s_)
and tSolveFirst = mSettings(m, 't_start') // Only apply for the very first solve
and [
[ p_gn(grid, node, 'boundCyclic') // Bind variables if parameter found
and ord(s) = ord(s_) // Select the same sample
......@@ -1339,36 +1338,27 @@ q_boundCyclic(gn_state(grid, node), ms(m, s), s_)${ ms(m, s_)
or
[ p_gn(grid, node, 'boundCyclicBetweenSamples')
and [ ord(s_) = ord(s) - 1 // Select consecutive samples
or [ord(s_) = mSettings(m, 'samples') and ord (s) = 1]
or [ord(s_) = mSettings(m, 'samples') and ord(s) = 1]
] // END and
] // END or
] // END and
}..
// Initial value of the state of the node at the start of the sample
+ sum(mft_start(m, f, t)${ p_gn(grid, node, 'boundCyclic')},
+ v_state(grid, node, f, t)
) // END sum(mftStart)
+ sum(mft_start(m, f, t)${ p_gn(grid, node, 'boundCyclicBetweenSamples')
and ord(t) = msStart(m, s)
},
+ v_state(grid, node, f, t)
) // END sum(mftStart)
+ sum(mst_start(m, s, t),
+ sum(ft(f, t),
+ v_state(grid, node, f, t+dt(t))
) // END sum(ft)
) // END sum(mst_start)
=E=
// State of the node at the end of horizon
+ sum(mft_lastSteps(mf_central(m, f_), t_)${ p_gn(grid, node, 'boundCyclic') },
+ v_state(grid, node, f_, t_)
) // END sum(mftLastSteps)
// State of the node at the end of the sample, BoundCyclicBetweenSamples
+ sum(mft_lastSteps(mf_central(m, f_), t_)${ p_gn(grid, node, 'boundCyclicBetweenSamples')
and ord(t_) = msEnd(m, s_)
},
+ v_state(grid, node, f_, t_)
) // END sum(ft)
// State of the node at the end of the sample
+ sum(mst_end(m, s_, t_),
+ sum(ft(f_, t_),
+ v_state(grid, node, f_, t_)
) // END sum(ft)
) // END sum(mst_end)
;
*--- Minimum Inertia ----------------------------------------------------------
......
......@@ -349,6 +349,28 @@ mft_lastSteps(mSolve, ft(f,t))${ ord(t) + p_stepLength(mSolve, f, t) / mSettings
= yes
;
// Sample start and end intervals
loop(ms(mSolve, s),
tmp = 1;
tmp_ = 1;
loop(t_active(t),
if(tmp and ord(t) > msStart(mSolve, s),
mst_start(mSolve, s, t) = yes;
tmp = 0;
);
if(tmp_ and ord(t) > msEnd(mSolve, s),
mst_end(mSolve, s, t+dt(t)) = yes;
tmp_ = 0;
);
); // END loop(t_active)
// If the last interval of a sample is in mft_lastSteps, the method above does not work
if(tmp_,
mst_end(mSolve, s, t)${sum(f_solve, mft_lastSteps(mSolve, f_solve, t))} = yes;
);
); // END loop(ms)
// Displacement from the first interval of a sample to the previous interval is always -1
dt(t)${sum(ms(mSolve, s), mst_start(mSolve, s, t))} = -1
* --- Determine various other forecast-time sets required for the model -------
// Set of realized time steps in the solve
......
......@@ -68,6 +68,23 @@ v_state.fx(gn_state(grid, node), ft(f, t))${ p_gn(grid, node, 'boundAll')
* p_gnBoundaryPropertiesForStates(grid, node, 'reference', 'multiplier')
;
// Bound also the intervals just before the start of each sample - currently just 'upwardLimit'&'useConstant' and 'downwardLimit'&'useConstant'
// Upper bound
v_state.up(gn_state(grid, node), f_solve, t+dt(t))${ p_gnBoundaryPropertiesForStates(grid, node, 'upwardLimit', 'useConstant')
and not df_central(f_solve,t)
and sum(ms(mSolve, s), mst_start(mSolve, s, t))
}
= p_gnBoundaryPropertiesForStates(grid, node, 'upwardLimit', 'constant')
* p_gnBoundaryPropertiesForStates(grid, node, 'upwardLimit', 'multiplier');
// Lower bound
v_state.lo(gn_state(grid, node), f_solve, t+dt(t))${ p_gnBoundaryPropertiesForStates(grid, node, 'downwardLimit', 'useConstant')
and not df_central(f_solve,t)
and sum(ms(mSolve, s), mst_start(mSolve, s, t))
}
= p_gnBoundaryPropertiesForStates(grid, node, 'downwardLimit', 'constant')
* p_gnBoundaryPropertiesForStates(grid, node, 'downwardLimit', 'multiplier');
// Spilling of energy from the nodes
// Max. & min. spilling, use constant value as base and overwrite with time series if desired
v_spill.lo(gn(grid, node_spill), ft(f, t))${ p_gnBoundaryPropertiesForStates(grid, node_spill, 'minSpill', 'constant') }
......
......@@ -37,6 +37,13 @@ if(tSolveFirst >= mSettings(mSolve, 'results_t_start') - mSettings(mSolve, 't_ju
r_state(gn_state(grid, node), ft_realized(f, t))$[ord(t) > mSettings(mSolve, 'results_t_start')]
= v_state.l(grid, node, f, t)
;
// Realized state history - initial state values in samples
r_state(gn_state(grid, node), f_solve(f), t+dt(t))${ ord(t) > mSettings(mSolve, 'results_t_start')
and sum(ms(mSolve, s), mst_start(mSolve, s, t))
and ft_realized(f, t)
}
= v_state.l(grid, node, f, t+dt(t))
;
// Realized unit online history
r_online(uft_online(unit, ft_realized(f, t)))$[ord(t) > mSettings(mSolve, 'results_t_start')]
= v_online_LP.l(unit, f, t)${ uft_onlineLP(unit, f, t) }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment