1 from empro.toolkit import Bunch
2 from empro.toolkit.results import UnavailableError, excitation_based
3
4 INTERPOLATION_UNDEFINED, INTERPOLATION_NONE, INTERPOLATION_CLOSEST_VALUE = 0,1,2
5
13
17
27
32
37
39
40 return [self._circuitMatrix.Zref(i) for i in range(self._circuitMatrix.size())]
41
43 """
44 activeSparam(frequency, excitation)
45 @type frequency: double
46 @param frequency: frequency of interest
47 @type excitation: map from string to to voltage or current excitation
48 @param excitation: a map from port name to voltage or current excitation (example: {"p1": excitation.VoltageSource(V=1,load=excitation.ParallelRLC(50))}
49 @rtype: list of complex numbers
50 @return: list of active S params for each port under given excitation
51 """
52 s = self.S(frequency, interpolation)
53 activeS = []
54 excitationBase = self._results.excitationBased( excitation = excitation, frequencies = frequency )
55 excitationWeights = excitationBase.weights(frequency)
56 voltage = []
57 voltageId = 0
58 for i in range(len(self._availableExcitations)):
59 portName = self._availableExcitations[i]
60 if portName in excitationWeights:
61 value = excitationWeights[portName]
62 voltage.append(value)
63 else:
64 raise RuntimeError("The port %s does not excist in the excitation map"%(portName))
65 for i in range(s.size()):
66 thisS = 0.0
67 for j in range(s.size()):
68 thisS += s(i,j)*voltage[ j ]
69 if ( voltage[i] != 0 ):
70 activeS.append( thisS/voltage[ i ] )
71 else:
72 raise RuntimeError("The voltage of the port is equal to zero!")
73 return activeS
74