summaryrefslogtreecommitdiff
path: root/src/ngspicetoModelica/NgspicetoModelica.py
diff options
context:
space:
mode:
authorfahim-oscad2016-04-21 14:46:23 +0530
committerfahim-oscad2016-04-21 14:46:23 +0530
commit955682e89b02d66b1985687cd1d2466f6c06320e (patch)
treeb9d90714bf3bceffd8d720c93ec9d20fc777ddc3 /src/ngspicetoModelica/NgspicetoModelica.py
parentb5ae41e385deab139479d3992d99edcaf895fc2f (diff)
downloadeSim-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/NgspicetoModelica.py')
-rw-r--r--src/ngspicetoModelica/NgspicetoModelica.py44
1 files changed, 41 insertions, 3 deletions
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