@@ -352,50 +352,6 @@ function but_ordered_incidence(ts::TearingState, varmask = highest_order_variabl
352
352
mm[[var_eq_matching[v] for v in vordering if var_eq_matching[v] isa Int], vordering], bb
353
353
end
354
354
355
- # debugging use
356
- function reordered_matrix (sys, torn_matching)
357
- s = TearingState (sys)
358
- complete! (s. structure)
359
- @unpack graph = s. structure
360
- eqs = equations (sys)
361
- nvars = ndsts (graph)
362
- max_matching = complete (maximal_matching (graph))
363
- torn_matching = complete (torn_matching)
364
- sccs = find_var_sccs (graph, max_matching)
365
- I, J = Int[], Int[]
366
- ii = 0
367
- M = Int[]
368
- solved = BitSet (findall (torn_matching .!= = unassigned))
369
- for vars in sccs
370
- append! (M, filter (in (solved), vars))
371
- append! (M, filter (! in (solved), vars))
372
- end
373
- M = invperm (vcat (M, setdiff (1 : nvars, M)))
374
- for vars in sccs
375
- e_solved = [torn_matching[v] for v in vars if torn_matching[v] != = unassigned]
376
- for es in e_solved
377
- isdiffeq (eqs[es]) && continue
378
- ii += 1
379
- js = [M[x] for x in 𝑠neighbors (graph, es) if isalgvar (s. structure, x)]
380
- append! (I, fill (ii, length (js)))
381
- append! (J, js)
382
- end
383
-
384
- e_residual = setdiff (
385
- [max_matching[v]
386
- for v in vars if max_matching[v] != = unassigned], e_solved)
387
- for er in e_residual
388
- isdiffeq (eqs[er]) && continue
389
- ii += 1
390
- js = [M[x] for x in 𝑠neighbors (graph, er) if isalgvar (s. structure, x)]
391
- append! (I, fill (ii, length (js)))
392
- append! (J, js)
393
- end
394
- end
395
- # only plot algebraic variables and equations
396
- sparse (I, J, true )
397
- end
398
-
399
355
"""
400
356
uneven_invmap(n::Int, list)
401
357
@@ -432,23 +388,6 @@ function torn_system_jacobian_sparsity(sys)
432
388
return sparse (I, J, true , neqs, neqs)
433
389
end
434
390
435
- # ##
436
- # ## Nonlinear equation(s) solving
437
- # ##
438
-
439
- @noinline function nlsolve_failure (rc)
440
- error (" The nonlinear solver failed with the return code $rc ." )
441
- end
442
-
443
- function numerical_nlsolve (f, u0, p)
444
- prob = NonlinearProblem {false} (f, u0, p)
445
- sol = solve (prob, SimpleNewtonRaphson ())
446
- rc = sol. retcode
447
- (rc == ReturnCode. Success) || nlsolve_failure (rc)
448
- # TODO : robust initial guess, better debugging info, and residual check
449
- sol. u
450
- end
451
-
452
391
# ##
453
392
# ## Misc
454
393
# ##
0 commit comments