@@ -952,20 +952,41 @@ def simulate(self,
952952
953953 self ._simulationFlag = True
954954
955- # to extract simulation results
956- def getSolutions (self , varList = None , resultfile = None ): # 12
957- """
958- This method returns tuple of numpy arrays. It can be called:
959- •with a list of quantities name in string format as argument: it returns the simulation results of the corresponding names in the same order. Here it supports Python unpacking depending upon the number of variables assigned.
960- usage:
961- >>> getSolutions()
962- >>> getSolutions("Name1")
963- >>> getSolutions(["Name1","Name2"])
964- >>> getSolutions(resultfile="c:/a.mat")
965- >>> getSolutions("Name1",resultfile=""c:/a.mat"")
966- >>> getSolutions(["Name1","Name2"],resultfile=""c:/a.mat"")
955+ def getSolutions (self , varList : Optional [str | list [str ]] = None , resultfile : Optional [str ] = None ) -> tuple [str ] | np .ndarray :
956+ """Extract simulation results from a result data file.
957+
958+ Args:
959+ varList: Names of variables to be extracted. Either unspecified to
960+ get names of available variables, or a single variable name
961+ as a string, or a list of variable names.
962+ resultfile: Path to the result file. If unspecified, the result
963+ file created by simulate() is used.
964+
965+ Returns:
966+ If varList is None, a tuple with names of all variables
967+ is returned.
968+ If varList is a string, a 1D numpy array is returned.
969+ If varList is a list, a 2D numpy array is returned.
970+
971+ Examples:
972+ >>> mod.getSolutions()
973+ ('a', 'der(x)', 'time', 'x')
974+ >>> mod.getSolutions("x")
975+ np.array([[1. , 0.90483742, 0.81873075]])
976+ >>> mod.getSolutions(["x", "der(x)"])
977+ np.array([[1. , 0.90483742 , 0.81873075],
978+ [-1. , -0.90483742, -0.81873075]])
979+ >>> mod.getSolutions(resultfile="c:/a.mat")
980+ ('a', 'der(x)', 'time', 'x')
981+ >>> mod.getSolutions("x", resultfile="c:/a.mat")
982+ np.array([[1. , 0.90483742, 0.81873075]])
983+ >>> mod.getSolutions(["x", "der(x)"], resultfile="c:/a.mat")
984+ np.array([[1. , 0.90483742 , 0.81873075],
985+ [-1. , -0.90483742, -0.81873075]])
967986 """
968987 if resultfile is None :
988+ if self ._resultfile is None :
989+ raise ModelicaSystemError ("No result file found. Run simulate() first." )
969990 resFile = self ._resultfile .as_posix ()
970991 else :
971992 resFile = resultfile
0 commit comments