MCPcopy Create free account
hub / github.com/SLiCAP/SLiCAP_python / _checkElementModelParams

Function _checkElementModelParams

SLiCAP/SLiCAPyacc.py:776–846  ·  view source on GitHub ↗

Checks the model parameters used in elements that are not subcircuits (X). If the model parameters correspond with those of the prototype, the values will be passed to the instance of the prototype. if no values are given with the element, default values of the prototype will be use

(circuitObject, el)

Source from the content-addressed store, hash-verified

774 circuitObject = _checkSubCircuitElementModelParams(circuitObject, circuitObject.elements[elementNames[i]])
775
776def _checkElementModelParams(circuitObject, el):
777 """
778 Checks the model parameters used in elements that are not subcircuits (X).
779 If the model parameters correspond with those of the prototype, the values
780 will be passed to the instance of the prototype. if no values are given
781 with the element, default values of the prototype will be used.
782
783 If the model requires expansion then its model attribute will be replaced
784 with its prototype subcircuit.
785
786 :param circuitObject: Circuit object that holds the element.
787 :type circuitObject: SLiCAPprotos.circuit
788
789 :param el: Element that needs to be checked
790 :type el: SLiCAPprotos.element
791
792 :return: circuit object with updated element el.
793 :rtype: SLiCAPprotos.circuit
794 """
795 modelParams = {}
796 elModel = el.model
797 if elModel == '':
798 basicModel = _DEVICES[el.type].models[0]
799 elif elModel in _DEVICES[el.type].models:
800 basicModel = elModel
801 elif elModel != '' and elModel not in _DEVICES[el.type].models:
802 # If not present in the circuit model definitions, find it in the libraries
803 # and replace the model name with the base model and parameters
804 if elModel in circuitObject.modelDefs.keys():
805 modelParams = circuitObject.modelDefs[elModel].params
806 basicModel = circuitObject.modelDefs[elModel].type
807 elif elModel in _USERMODELS.keys():
808 modelParams = _USERMODELS[elModel].params
809 basicModel = _USERMODELS[elModel].type
810 elif elModel in _SLiCAPMODELS.keys():
811 modelParams = _SLiCAPMODELS[elModel].params
812 basicModel = _SLiCAPMODELS[elModel].type
813 else:
814 print("Error: missing definition of model: " + str(elModel) + ".")
815 circuitObject.errors += 1
816 basicModel = False
817 # Assign basic model to element
818 el.model = basicModel
819 # Check parameter names and complete the list of parameters with default values
820 givenParams = el.params
821 allParams = _MODELS[basicModel].params
822 for parName in givenParams:
823 if parName not in allParams:
824 circuitObject.errors += 1
825 print("Error: unknown parameter '%s' for element '%s' in circuit '%s'."%(parName, el.refDes, circuitObject.title))
826 elif _MODELS[basicModel].params[parName] == False:
827 # Laplace variable not allowed inexpression.
828 if ini.laplace in el.params[parName].atoms(sp.Symbol):
829 print("Error: Laplace variable not allowed in expression of %s."%(el.refDes))
830 for parName in allParams.keys():
831 if parName not in givenParams.keys():
832 if parName not in modelParams:
833 # Assign default values to missing parameters

Callers 1

_checkElementModelFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected