Skip to content

Commit

Permalink
One more test for WSCC9
Browse files Browse the repository at this point in the history
  • Loading branch information
lisawim committed Nov 9, 2023
1 parent c0ff22e commit f34065d
Showing 1 changed file with 78 additions and 0 deletions.
78 changes: 78 additions & 0 deletions pySDC/tests/test_projects/test_DAE/test_problems.py
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,84 @@ def test_WSCC9_update_YBus():
), 'YBus after line outage does not match with the one it should supposed to!'


@pytest.mark.base
def test_WSCC9_SDC_detection():
"""
Test if state function states a root.
"""

from pySDC.helpers.stats_helper import get_sorted
from pySDC.projects.DAE.problems.WSCC9BusSystem import WSCC9BusSystem, get_initial_Ybus, get_event_Ybus
from pySDC.projects.DAE.sweepers.fully_implicit_DAE import fully_implicit_DAE
from pySDC.implementations.controller_classes.controller_nonMPI import controller_nonMPI
from pySDC.projects.PinTSimE.switch_estimator import SwitchEstimator
from pySDC.implementations.convergence_controller_classes.basic_restarting import BasicRestartingNonMPI

dt = 0.75
level_params = {
'restol': 5e-13,
'dt': dt,
}

problem_params = {
'newton_tol': 1e-10,
}

sweeper_params = {
'quad_type': 'RADAU-RIGHT',
'num_nodes': 2,
'QI': 'LU',
}

step_params = {
'maxiter': 8,
}

controller_params = {
'logger_level': 30,
}

switch_estimator_params = {
'tol': 1e-10,
'alpha': 0.95,
}

restarting_params = {
'max_restarts': 200,
'crash_after_max_restarts': False,
}

convergence_controllers = {
SwitchEstimator: switch_estimator_params,
BasicRestartingNonMPI: restarting_params,
}

description = {
'problem_class': WSCC9BusSystem,
'problem_params': problem_params,
'sweeper_class': fully_implicit_DAE,
'sweeper_params': sweeper_params,
'level_params': level_params,
'step_params': step_params,
'convergence_controllers': convergence_controllers,
}

controller = controller_nonMPI(num_procs=1, controller_params=controller_params, description=description)

t0 = 0.0
Tend = dt

P = controller.MS[0].levels[0].prob
uinit = P.u_exact(t0)

uend, stats = controller.run(u0=uinit, t0=t0, Tend=Tend)

switches = get_sorted(stats, type='switch', sortby='time', recomputed=False)
assert len(switches) >= 1, 'ERROR: No events found!'
t_switch = [me[1] for me in switches][0]
assert np.isclose(t_switch, 0.6103290792685618, atol=1e-3), 'Found event does not match a threshold!'


# @pytest.mark.base
# def test_WSCC9_SDC_detection():
# """
Expand Down

0 comments on commit f34065d

Please sign in to comment.