@@ -193,14 +193,14 @@ end
193193=# 
194194
195195""" 
196- Replace derivatives of non-selected unknown variables by dummy derivatives.   
196+ Replace derivatives of non-selected unknown variables by dummy derivatives. 
197197
198198State selection may determine that some differential variables are 
199199algebraic variables in disguise. The derivative of such variables are 
200200called dummy derivatives. 
201201
202- `SelectedState` information is no longer needed after this function is called.   
203- State selection is done. All non-differentiated variables are algebraic   
202+ `SelectedState` information is no longer needed after this function is called. 
203+ State selection is done. All non-differentiated variables are algebraic 
204204variables, and all variables that appear differentiated are differential variables. 
205205""" 
206206function  substitute_derivatives_algevars! (
@@ -241,7 +241,7 @@ function substitute_derivatives_algevars!(
241241    end 
242242end 
243243
244- #=   
244+ #= 
245245There are three cases where we want to generate new variables to convert 
246246the system into first order (semi-implicit) ODEs. 
247247
@@ -288,32 +288,32 @@ where `:=` denotes assignment.
288288As a final note, in all the above cases where we need to introduce new 
289289variables and equations, don't add them when they already exist. 
290290
291- ###### DISCRETE SYSTEMS #######   
291+ ###### DISCRETE SYSTEMS ####### 
292292
293293Documenting the differences to structural simplification for discrete systems: 
294294
295295In discrete systems everything gets shifted forward a timestep by `shift_discrete_system` 
296- in order to properly generate the difference equations.   
296+ in order to properly generate the difference equations. 
297297
298298In the system x(k) ~ x(k-1) + x(k-2), becomes Shift(t, 1)(x(t)) ~ x(t) + Shift(t, -1)(x(t)) 
299299
300- The lowest-order term is Shift(t, k)(x(t)), instead of x(t). As such we actually want   
300+ The lowest-order term is Shift(t, k)(x(t)), instead of x(t). As such we actually want 
301301dummy variables for the k-1 lowest order terms instead of the k-1 highest order terms. 
302302
303303Shift(t, -1)(x(t)) -> x\_{t-1}(t) 
304304
305- Since Shift(t, -1)(x) is not a derivative, it is directly substituted in `fullvars`.   
306- No equation or variable is added for it.   
305+ Since Shift(t, -1)(x) is not a derivative, it is directly substituted in `fullvars`. 
306+ No equation or variable is added for it. 
307307
308- For ODESystems D(D(D(x))) in equations is recursively substituted as D(x) ~ x_t, D(x_t) ~ x_tt, etc.   
309- The analogue for discrete systems, Shift(t, 1)(Shift(t,1)(Shift(t,1)(Shift(t, -3)(x(t)))))   
310- does not actually appear. So `total_sub` in generate_system_equations` is directly   
311- initialized with all of the lowered variables `Shift(t, -3)(x) -> x_t-3(t)`, etc.   
308+ For ODESystems D(D(D(x))) in equations is recursively substituted as D(x) ~ x_t, D(x_t) ~ x_tt, etc. 
309+ The analogue for discrete systems, Shift(t, 1)(Shift(t,1)(Shift(t,1)(Shift(t, -3)(x(t))))) 
310+ does not actually appear. So `total_sub` in generate_system_equations` is directly 
311+ initialized with all of the lowered variables `Shift(t, -3)(x) -> x_t-3(t)`, etc. 
312312=# 
313313""" 
314314Generate new derivative variables for the system. 
315315
316- Effects on the system structure:   
316+ Effects on the system structure: 
317317- fullvars: add the new derivative variables x_t 
318318- neweqs: add the identity equations for the new variables, D(x) ~ x_t 
319319- graph: update graph with the new equations and variables, and their connections 
@@ -484,7 +484,7 @@ function find_duplicate_dd(dv, solvable_graph, diff_to_var, linear_eqs, mm)
484484end 
485485
486486""" 
487- Add a dummy derivative variable x_t corresponding to symbolic variable D(x)   
487+ Add a dummy derivative variable x_t corresponding to symbolic variable D(x) 
488488which has index dv in `fullvars`. Return the new index of x_t. 
489489""" 
490490function  add_dd_variable! (s:: SystemStructure , fullvars, x_t, dv)
@@ -516,22 +516,22 @@ function add_dd_equation!(s::SystemStructure, neweqs, eq, dv, v_t)
516516end 
517517
518518""" 
519- Solve the equations in `neweqs` to obtain the final equations of the   
519+ Solve the equations in `neweqs` to obtain the final equations of the 
520520system. 
521521
522- For each equation of `neweqs`, do one of the following:   
522+ For each equation of `neweqs`, do one of the following: 
523523   1. If the equation is solvable for a differentiated variable D(x), 
524524      then solve for D(x), and add D(x) ~ sol as a differential equation 
525525      of the system. 
526-    2. If the equation is solvable for an un-differentiated variable x,   
526+    2. If the equation is solvable for an un-differentiated variable x, 
527527      solve for x and then add x ~ sol as a solved equation. These will 
528528      become observables. 
529529   3. If the equation is not solvable, add it as an algebraic equation. 
530530
531531Solved equations are added to `total_sub`. Occurrences of differential 
532532or solved variables on the RHS of the final equations will get substituted. 
533533The topological sort of the equations ensures that variables are solved for 
534- before they appear in equations.   
534+ before they appear in equations. 
535535
536536Reorder the equations and unknowns to be in the BLT sorted form. 
537537
@@ -610,7 +610,7 @@ function generate_system_equations!(state::TearingState, neweqs, var_eq_matching
610610    @unpack  neweqs′, eq_ordering, var_ordering, solved_eqs, solved_vars =  eq_generator
611611
612612    is_diff_eq =  .! iszero .(var_ordering)
613-     #  Generate new equations and orderings  
613+     #  Generate new equations and orderings
614614    diff_vars =  var_ordering[is_diff_eq]
615615    diff_vars_set =  BitSet (diff_vars)
616616    if  length (diff_vars_set) !=  length (diff_vars)
@@ -695,7 +695,7 @@ struct EquationGenerator{S, D, I}
695695    neweqs′:: Vector{Equation} 
696696    """ 
697697    `eq_ordering[i]` is the index `neweqs′[i]` was originally at in the untorn equations of 
698-     the system. This is used to permute the state of the system into BLT sorted form.   
698+     the system. This is used to permute the state of the system into BLT sorted form. 
699699    """  
700700    eq_ordering:: Vector{Int} 
701701    """ 
@@ -866,7 +866,7 @@ function make_solved_equation(var, eq, total_sub; simplify = false)
866866end 
867867
868868""" 
869- Given the ordering returned by `generate_system_equations!`, update the   
869+ Given the ordering returned by `generate_system_equations!`, update the 
870870tearing state to account for the new order. Permute the variables and equations. 
871871Eliminate the solved variables and equations from the graph and permute the 
872872graph's vertices to account for the new variable/equation ordering. 
@@ -916,7 +916,7 @@ function reorder_vars!(state::TearingState, var_eq_matching, var_sccs, eq_orderi
916916    #  Remove empty SCCs
917917    filter! (! isempty, var_sccs)
918918
919-     #  Update system structure  
919+     #  Update system structure
920920    @set!  state. structure. graph =  complete (new_graph)
921921    @set!  state. structure. var_to_diff =  new_var_to_diff
922922    @set!  state. structure. eq_to_diff =  new_eq_to_diff
@@ -933,7 +933,7 @@ function update_simplified_system!(
933933    @unpack  fullvars, structure =  state
934934    @unpack  solvable_graph, var_to_diff, eq_to_diff, graph =  structure
935935    diff_to_var =  invview (var_to_diff)
936-     #  Since we solved the highest order derivative varible  in discrete systems,
936+     #  Since we solved the highest order derivative variable  in discrete systems,
937937    #  we make a list of the solved variables and avoid including them in the
938938    #  unknowns.
939939    solved_vars =  Set ()
@@ -1058,7 +1058,7 @@ function tearing_reassemble(state::TearingState, var_eq_matching::Matching,
10581058            state, neweqs, var_eq_matching, full_var_eq_matching, var_sccs; iv, D)
10591059    end 
10601060
1061-     #  Structural simplification  
1061+     #  Structural simplification
10621062    substitute_derivatives_algevars! (state, neweqs, var_eq_matching, dummy_sub; iv, D)
10631063
10641064    var_sccs =  generate_derivative_variables! (
0 commit comments