@@ -1412,9 +1412,10 @@ def __init__(self, io_sys, ss_sys=None):
14121412 raise TypeError ("Second argument must be a state space system." )
14131413
14141414
1415- def input_output_response (sys , T , U = 0. , X0 = 0 , params = {}, method = 'RK45' ,
1416- transpose = False , return_x = False , squeeze = None ):
1417-
1415+ def input_output_response (
1416+ sys , T , U = 0. , X0 = 0 , params = {},
1417+ transpose = False , return_x = False , squeeze = None ,
1418+ solve_ivp_kwargs = {}, ** kwargs ):
14181419 """Compute the output response of a system to a given input.
14191420
14201421 Simulate a dynamical system with a given input and return its output
@@ -1457,7 +1458,33 @@ def input_output_response(sys, T, U=0., X0=0, params={}, method='RK45',
14571458 ValueError
14581459 If time step does not match sampling time (for discrete time systems)
14591460
1461+ Additional parameters
1462+ ---------------------
1463+ solve_ivp_method : str, optional
1464+ Set the method used by :func:`scipy.integrate.solve_ivp`. Defaults
1465+ to 'RK45'.
1466+ solve_ivp_kwargs : str, optional
1467+ Pass additional keywords to :func:`scipy.integrate.solve_ivp`.
1468+
14601469 """
1470+ #
1471+ # Process keyword arguments
1472+ #
1473+
1474+ # Allow method as an alternative to solve_ivp_method
1475+ if kwargs .get ('method' , None ):
1476+ solve_ivp_kwargs ['method' ] = kwargs .pop ('method' )
1477+
1478+ # Figure out the method to be used
1479+ if kwargs .get ('solve_ivp_method' , None ):
1480+ if kwargs .get ('method' , None ):
1481+ raise ValueError ("ivp_method specified more than once" )
1482+ solve_ivp_kwargs ['method' ] = kwargs ['solve_ivp_method' ]
1483+
1484+ # Set the default method to 'RK45'
1485+ if solve_ivp_kwargs .get ('method' , None ) is None :
1486+ solve_ivp_kwargs ['method' ] = 'RK45'
1487+
14611488 # Sanity checking on the input
14621489 if not isinstance (sys , InputOutputSystem ):
14631490 raise TypeError ("System of type " , type (sys ), " not valid" )
@@ -1504,8 +1531,9 @@ def ivp_rhs(t, x): return sys._rhs(t, x, u(t))
15041531 if not hasattr (sp .integrate , 'solve_ivp' ):
15051532 raise NameError ("scipy.integrate.solve_ivp not found; "
15061533 "use SciPy 1.0 or greater" )
1507- soln = sp .integrate .solve_ivp (ivp_rhs , (T0 , Tf ), X0 , t_eval = T ,
1508- method = method , vectorized = False )
1534+ soln = sp .integrate .solve_ivp (
1535+ ivp_rhs , (T0 , Tf ), X0 , t_eval = T ,
1536+ vectorized = False , ** solve_ivp_kwargs )
15091537
15101538 # Compute the output associated with the state (and use sys.out to
15111539 # figure out the number of outputs just in case it wasn't specified)
0 commit comments