diff options
author | fahim-oscad | 2016-04-21 14:46:23 +0530 |
---|---|---|
committer | fahim-oscad | 2016-04-21 14:46:23 +0530 |
commit | 955682e89b02d66b1985687cd1d2466f6c06320e (patch) | |
tree | b9d90714bf3bceffd8d720c93ec9d20fc777ddc3 /src/ngspicetoModelica | |
parent | b5ae41e385deab139479d3992d99edcaf895fc2f (diff) | |
download | eSim-955682e89b02d66b1985687cd1d2466f6c06320e.tar.gz eSim-955682e89b02d66b1985687cd1d2466f6c06320e.tar.bz2 eSim-955682e89b02d66b1985687cd1d2466f6c06320e.zip |
Inbuilt model of Ngspice is mapped(Only Zener is mapped for time being)
Diffstat (limited to 'src/ngspicetoModelica')
-rw-r--r-- | src/ngspicetoModelica/Mapping.json | 28 | ||||
-rw-r--r-- | src/ngspicetoModelica/NgspicetoModelica.py | 44 |
2 files changed, 63 insertions, 9 deletions
diff --git a/src/ngspicetoModelica/Mapping.json b/src/ngspicetoModelica/Mapping.json index 3ecc26a2..5ebd2aff 100644 --- a/src/ngspicetoModelica/Mapping.json +++ b/src/ngspicetoModelica/Mapping.json @@ -25,15 +25,31 @@ "Q": "Analog.Semiconductors", "q": "Analog.Semiconductors" }, - "Parameters":{ - "Diode":"List Of Diode Param", - "Mosfet":"List of Mosfet Param" - }, + "Models":{ - - }, + "zener":{ + "import":"Analog.Semiconductors.ZDiode", + "mapping":{ + "v_breakdown":"Bv", + "i_breakdown":"Ibv", + "i_sat":"Ids", + "n_forward":"Nbv" + + }, + "default":{ + "Ids":"880.5e-18", + "Vt":"0.025", + "R":"1e12", + "Bv":"8.1", + "Ibv":"0.020245", + "Nbv":"1.6989" + } + + } + }, + "Units":{ "k":"e3", "u":"e-6", diff --git a/src/ngspicetoModelica/NgspicetoModelica.py b/src/ngspicetoModelica/NgspicetoModelica.py index 56225b30..72e2c6eb 100644 --- a/src/ngspicetoModelica/NgspicetoModelica.py +++ b/src/ngspicetoModelica/NgspicetoModelica.py @@ -18,7 +18,7 @@ class NgMoConverter: self.subCktDetail = [] self.inbuiltModelDetail = [] self.deviceList = ['d','D','j','J','q','Q'] #MOSFET is excluded as it has special case - self.inbuiltModelList = {} + self.inbuiltModelDict = {} def readNetlist(self,filename): @@ -113,6 +113,8 @@ class NgMoConverter: transInfo[trans] = [] if templine[2] in ['npn', 'pnp', 'pmos', 'nmos']: transInfo[trans] = templine[2] + else: + self.inbuiltModelDict[model]=templine[2] eachline[1] = eachline[1].lower() eachline = eachline[1].split() @@ -407,9 +409,45 @@ class NgMoConverter: #Lets start for inbuilt model of ngspice for eachline in self.inbuiltModelDetail: - print "each line of inbuilt Model------->",eachline - print "Model Info--------->",modelInfo + words=eachline.split() + userModelParamList = [] + #print "Model Info--------->",modelInfo + #print "Inbuilt Model Mapped to ref---------->",self.inbuiltModelDict + refName = words[-1] + print "Reference Model Name------->",refName + actualModelName = self.inbuiltModelDict[refName] + print "Actual Model Name------->",actualModelName + start = self.mappingData["Models"][actualModelName]["import"] + print "Import Statement-------->",start + stat = start +" "+ words[0]+"(" + tempstatList=[] + print "Start Stat-------->",stat + for key in modelInfo[refName]: + #If parameter is not mapped then it will just pass + try: + actualModelicaParam = self.mappingData["Models"][actualModelName]["mapping"][key] + tempstatList.append(actualModelicaParam+"="+modelInfo[refName][actualModelicaParam]+" ") + userModelParamList.append(str(actualModelicaParam)) + except: + pass + print "User Model list---->",userModelParamList + + #Running loop over default parameter of OpenModelica + for default in self.mappingData["Models"][actualModelName]["default"]: + if default in userModelParamList: + continue + else: + defaultValue = self.mappingData["Models"][actualModelName]["default"][default] + tempstatList.append(default+"="+defaultValue+" ") + + #print "My Stat------------>",stat + #print "Temp Stat List--------->",tempstatList + stat += ",".join(str(item) for item in tempstatList)+");" + print "End Stat---------->",stat + modelicaCompInit.append(stat) + + #Lets start for Subcircuit for eachline in self.subCktDetail: global point |