summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrahulp132020-04-20 11:47:10 +0530
committerrahulp132020-04-20 11:47:10 +0530
commit29074935e8ae45bd8008cbc477be1f71baf0b857 (patch)
tree1a2d6f61c39d4a27c21feda07fab07b54291c2d2
parent258fad3a4556915c9fba9981e52fd1289071f7f8 (diff)
downloadeSim-29074935e8ae45bd8008cbc477be1f71baf0b857.tar.gz
eSim-29074935e8ae45bd8008cbc477be1f71baf0b857.tar.bz2
eSim-29074935e8ae45bd8008cbc477be1f71baf0b857.zip
update to Diode model, resolves issue with duplicate nodes
-rw-r--r--library/ngspicetoModelica/Mapping.json65
-rw-r--r--src/ngspicetoModelica/NgspicetoModelica.py50
2 files changed, 71 insertions, 44 deletions
diff --git a/library/ngspicetoModelica/Mapping.json b/library/ngspicetoModelica/Mapping.json
index b7c8df5d..d0c4fb1c 100644
--- a/library/ngspicetoModelica/Mapping.json
+++ b/library/ngspicetoModelica/Mapping.json
@@ -27,22 +27,55 @@
},
"Devices":{
"d":{
- "import":"Analog.Semiconductors.Diode",
+ "import":"Spice3.Internal.DIODE",
+ "modelcard":"Spice3.Semiconductors.ModelcardDIODE",
"mapping":{
- "is":"Ids"
+ "is":"IS",
+ "rs":"RS",
+ "n":"N",
+ "tt":"TT",
+ "cjo":"CJO",
+ "vj":"VJ",
+ "m":"M",
+ "eg":"EG",
+ "xti":"XTI",
+ "fc":"FC",
+ "bv":"BV",
+ "ibv":"IBV",
+ "tnom":"TNOM",
+ "kf":"KF",
+ "af":"AF",
+ "g":"G"
+
},
+
"default":{
- "Ids":"880.5e-18",
- "Vt":"0.025",
- "R":"1e12"
- }
+ "IS":"1e-14",
+ "RS":"0.0",
+ "N":"1.0",
+ "TT":"0.0",
+ "CJO":"0.0",
+ "VJ":"1.0",
+ "M":"0.5",
+ "EG":"1.11",
+ "XTI":"3.0",
+ "FC":"0.5",
+ "BV":"-1e40",
+ "IBV":"1e-3",
+ "TNOM":"27",
+ "KF":"0.0",
+ "AF":"1.0",
+ "G":"0"
+
+ }
},
"m":{
"import":"BondLib.Electrical.Analog.Spice",
"mapping":{
+
"tnom":"Tnom",
"vto":"VT0",
"gamma":"GAMMA",
@@ -61,8 +94,8 @@
"cgbo":"CGB0",
"cgso":"CGS0"
-
},
+
"default":{
"Tnom":"300",
"VT0":"0",
@@ -82,13 +115,13 @@
"CGB0":"0",
"CGS0":"0"
-
}
-
},
+
"q":{
"import":"Analog.Semiconductors",
"mapping":{
+
"bf":"Bf",
"br":"Br",
"is":"Is",
@@ -102,8 +135,11 @@
"mje":"Me",
"vjc":"Phic",
"mjc":"Mc"
+
},
+
"default":{
+
"Bf":"50",
"Br":"0.1",
"Is":"1e-16",
@@ -119,12 +155,13 @@
"Mc":"0.333"
}
-
},
- "j":{
+ "j":{
+
"import":"Spice3.Internal.JFET",
"mapping":{
+
"kf":"KF",
"rs":"RS",
"is":"IS",
@@ -142,6 +179,7 @@
},
"default":{
+
"KF":"0",
"RS":"0",
"IS":"1e-14",
@@ -156,13 +194,10 @@
"LAMBDA":"0",
"B":"1"
-
}
}
-
- },
+ },
-
"Models":{
"zener":{
"import":"Analog.Semiconductors.ZDiode",
diff --git a/src/ngspicetoModelica/NgspicetoModelica.py b/src/ngspicetoModelica/NgspicetoModelica.py
index 5dff56e0..75bb8a52 100644
--- a/src/ngspicetoModelica/NgspicetoModelica.py
+++ b/src/ngspicetoModelica/NgspicetoModelica.py
@@ -406,18 +406,9 @@ class NgMoConverter:
deviceName = eachline[0].lower()
if deviceName == 'd':
if len(words) > 3:
- if 'n' in modelInfo[words[3]]:
- n = float(modelInfo[words[3]]['n'])
- else:
- n = 1.0
- vt = str(float(0.025 * n))
- '''
- stat = self.mappingData["Devices"][deviceName]["import"]+\
- ' '+words[0] + '(Ids = ' + modelInfo[words[3]]['is']+\
- ', Vt = ' + vt + ', R = 1e12' +');'
- '''
- start = self.mappingData["Devices"][deviceName]["import"]
- stat = start + " " + words[0] + "("
+ start = "\nparameter "
+ start += self.mappingData["Devices"][deviceName]["modelcard"]
+ stat = start + " card" + words[0] + "("
tempstatList = []
userDeviceParamList = []
refName = words[-1]
@@ -432,17 +423,14 @@ class NgMoConverter:
)
tempstatList.append(
actualModelicaParam +
- "=" +
- self.getUnitVal(
- modelInfo[refName][key]) +
- " ")
+ " = " +
+ self.getUnitVal(modelInfo[refName][key])
+ )
userDeviceParamList.append(
str(actualModelicaParam))
except BaseException:
pass
- # Adding Vt and R
- userDeviceParamList.append("Vt")
- tempstatList.append("Vt=" + vt)
+
# Running loop over default parameter of OpenModelica
for default in (self.mappingData
["Devices"]
@@ -459,11 +447,14 @@ class NgMoConverter:
[default]
)
tempstatList.append(
- default + "=" +
- self.getUnitVal(defaultValue) + " ")
-
- stat += ",".join(str(item) for item in tempstatList) + ");"
-
+ default + " = " +
+ self.getUnitVal(defaultValue))
+
+ stat += ", ".join(str(item) for item in tempstatList)
+ stat += ");" + "\n\n"
+ stat += self.mappingData["Devices"][deviceName]["import"]
+ stat += " " + words[0] + "(modelcarddiode=card" + words[0]
+ stat += ");"
else:
stat = (self.mappingData
["Devices"]
@@ -942,8 +933,8 @@ class NgMoConverter:
# Replace hyphen '-' from node
for i in nodeTemp:
+ i = i.replace("-", "")
if i not in node:
- i = i.replace("-", "")
node.append(i)
for i in range(0, len(node), 1):
@@ -976,10 +967,11 @@ class NgMoConverter:
pinInit = pinInit + nodeDic[protectedNode[i]]
pinInit = pinInit + ';'
pinProtectedInit = pinProtectedInit + ';'
- # print "Node---->",node
- # print "nodeDic----->",nodeDic
- # print "PinInit----->",pinInit
- # print "pinProtectedinit--->",pinProtectedInit
+ # print ("Node---->",node)
+ # print ("nodeDic----->",nodeDic)
+ # print ("PinInit----->",pinInit)
+ # print ("pinProtectedinit--->",pinProtectedInit)
+
return node, nodeDic, pinInit, pinProtectedInit
def connectInfo(self, compInfo, node, nodeDic, numNodesSub, subcktName):