|
79 | 79 | from .. import margins |
80 | 80 | from ..statesp import * |
81 | 81 | from ..xferfcn import * |
82 | | -from ..lti import LTI # base class of StateSpace, TransferFunction |
83 | 82 | from ..lti import issiso |
84 | 83 | from ..frdata import FRD |
85 | 84 | from ..dtime import sample_system |
86 | 85 | from ..exception import ControlArgument |
| 86 | +from .timeresp import * |
87 | 87 |
|
88 | 88 | # Import MATLAB-like functions that can be used as-is |
89 | 89 | from ..ctrlutil import unwrap |
@@ -852,192 +852,6 @@ def damp(sys, doprint=True): |
852 | 852 | # Simulation routines |
853 | 853 | # Call corresponding functions in timeresp, with arguments transposed |
854 | 854 |
|
855 | | -def step(sys, T=None, X0=0., input=0, output=None): |
856 | | - ''' |
857 | | - Step response of a linear system |
858 | | -
|
859 | | - If the system has multiple inputs or outputs (MIMO), one input has |
860 | | - to be selected for the simulation. Optionally, one output may be |
861 | | - selected. If no selection is made for the output, all outputs are |
862 | | - given. The parameters `input` and `output` do this. All other |
863 | | - inputs are set to 0, all other outputs are ignored. |
864 | | -
|
865 | | - Parameters |
866 | | - ---------- |
867 | | - sys: StateSpace, or TransferFunction |
868 | | - LTI system to simulate |
869 | | -
|
870 | | - T: array-like object, optional |
871 | | - Time vector (argument is autocomputed if not given) |
872 | | -
|
873 | | - X0: array-like or number, optional |
874 | | - Initial condition (default = 0) |
875 | | -
|
876 | | - Numbers are converted to constant arrays with the correct shape. |
877 | | -
|
878 | | - input: int |
879 | | - Index of the input that will be used in this simulation. |
880 | | -
|
881 | | - output: int |
882 | | - If given, index of the output that is returned by this simulation. |
883 | | -
|
884 | | - Returns |
885 | | - ------- |
886 | | - yout: array |
887 | | - Response of the system |
888 | | -
|
889 | | - T: array |
890 | | - Time values of the output |
891 | | -
|
892 | | - See Also |
893 | | - -------- |
894 | | - lsim, initial, impulse |
895 | | -
|
896 | | - Examples |
897 | | - -------- |
898 | | - >>> yout, T = step(sys, T, X0) |
899 | | - ''' |
900 | | - T, yout = timeresp.step_response(sys, T, X0, input, output, |
901 | | - transpose = True) |
902 | | - return yout, T |
903 | | - |
904 | | -def impulse(sys, T=None, input=0, output=None): |
905 | | - ''' |
906 | | - Impulse response of a linear system |
907 | | -
|
908 | | - If the system has multiple inputs or outputs (MIMO), one input has |
909 | | - to be selected for the simulation. Optionally, one output may be |
910 | | - selected. If no selection is made for the output, all outputs are |
911 | | - given. The parameters `input` and `output` do this. All other |
912 | | - inputs are set to 0, all other outputs are ignored. |
913 | | -
|
914 | | - Parameters |
915 | | - ---------- |
916 | | - sys: StateSpace, TransferFunction |
917 | | - LTI system to simulate |
918 | | -
|
919 | | - T: array-like object, optional |
920 | | - Time vector (argument is autocomputed if not given) |
921 | | -
|
922 | | - input: int |
923 | | - Index of the input that will be used in this simulation. |
924 | | -
|
925 | | - output: int |
926 | | - Index of the output that will be used in this simulation. |
927 | | -
|
928 | | - Returns |
929 | | - ------- |
930 | | - yout: array |
931 | | - Response of the system |
932 | | - T: array |
933 | | - Time values of the output |
934 | | -
|
935 | | - See Also |
936 | | - -------- |
937 | | - lsim, step, initial |
938 | | -
|
939 | | - Examples |
940 | | - -------- |
941 | | - >>> yout, T = impulse(sys, T) |
942 | | - ''' |
943 | | - T, yout = timeresp.impulse_response(sys, T, 0, input, output, |
944 | | - transpose = True) |
945 | | - return yout, T |
946 | | - |
947 | | -def initial(sys, T=None, X0=0., input=None, output=None): |
948 | | - ''' |
949 | | - Initial condition response of a linear system |
950 | | -
|
951 | | - If the system has multiple outputs (?IMO), optionally, one output |
952 | | - may be selected. If no selection is made for the output, all |
953 | | - outputs are given. |
954 | | -
|
955 | | - Parameters |
956 | | - ---------- |
957 | | - sys: StateSpace, or TransferFunction |
958 | | - LTI system to simulate |
959 | | -
|
960 | | - T: array-like object, optional |
961 | | - Time vector (argument is autocomputed if not given) |
962 | | -
|
963 | | - X0: array-like object or number, optional |
964 | | - Initial condition (default = 0) |
965 | | -
|
966 | | - Numbers are converted to constant arrays with the correct shape. |
967 | | -
|
968 | | - input: int |
969 | | - This input is ignored, but present for compatibility with step |
970 | | - and impulse. |
971 | | -
|
972 | | - output: int |
973 | | - If given, index of the output that is returned by this simulation. |
974 | | -
|
975 | | - Returns |
976 | | - ------- |
977 | | - yout: array |
978 | | - Response of the system |
979 | | - T: array |
980 | | - Time values of the output |
981 | | -
|
982 | | - See Also |
983 | | - -------- |
984 | | - lsim, step, impulse |
985 | | -
|
986 | | - Examples |
987 | | - -------- |
988 | | - >>> yout, T = initial(sys, T, X0) |
989 | | -
|
990 | | - ''' |
991 | | - T, yout = timeresp.initial_response(sys, T, X0, output=output, |
992 | | - transpose=True) |
993 | | - return yout, T |
994 | | - |
995 | | -def lsim(sys, U=0., T=None, X0=0.): |
996 | | - ''' |
997 | | - Simulate the output of a linear system. |
998 | | -
|
999 | | - As a convenience for parameters `U`, `X0`: |
1000 | | - Numbers (scalars) are converted to constant arrays with the correct shape. |
1001 | | - The correct shape is inferred from arguments `sys` and `T`. |
1002 | | -
|
1003 | | - Parameters |
1004 | | - ---------- |
1005 | | - sys: LTI (StateSpace, or TransferFunction) |
1006 | | - LTI system to simulate |
1007 | | -
|
1008 | | - U: array-like or number, optional |
1009 | | - Input array giving input at each time `T` (default = 0). |
1010 | | -
|
1011 | | - If `U` is ``None`` or ``0``, a special algorithm is used. This special |
1012 | | - algorithm is faster than the general algorithm, which is used otherwise. |
1013 | | -
|
1014 | | - T: array-like |
1015 | | - Time steps at which the input is defined, numbers must be (strictly |
1016 | | - monotonic) increasing. |
1017 | | -
|
1018 | | - X0: array-like or number, optional |
1019 | | - Initial condition (default = 0). |
1020 | | -
|
1021 | | - Returns |
1022 | | - ------- |
1023 | | - yout: array |
1024 | | - Response of the system. |
1025 | | - T: array |
1026 | | - Time values of the output. |
1027 | | - xout: array |
1028 | | - Time evolution of the state vector. |
1029 | | -
|
1030 | | - See Also |
1031 | | - -------- |
1032 | | - step, initial, impulse |
1033 | | -
|
1034 | | - Examples |
1035 | | - -------- |
1036 | | - >>> yout, T, xout = lsim(sys, U, T, X0) |
1037 | | - ''' |
1038 | | - T, yout, xout = timeresp.forced_response(sys, T, U, X0, transpose = True) |
1039 | | - return yout, T, xout |
1040 | | - |
1041 | 855 | # Convert a continuous time system to a discrete time system |
1042 | 856 | def c2d(sysc, Ts, method='zoh'): |
1043 | 857 | ''' |
|
0 commit comments