summaryrefslogtreecommitdiff
path: root/src/ngspicetoModelica/NgspicetoModelica.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/ngspicetoModelica/NgspicetoModelica.py')
-rw-r--r--src/ngspicetoModelica/NgspicetoModelica.py64
1 files changed, 32 insertions, 32 deletions
diff --git a/src/ngspicetoModelica/NgspicetoModelica.py b/src/ngspicetoModelica/NgspicetoModelica.py
index a78bad1b..83df42a4 100644
--- a/src/ngspicetoModelica/NgspicetoModelica.py
+++ b/src/ngspicetoModelica/NgspicetoModelica.py
@@ -365,9 +365,9 @@ class NgMoConverter:
stat = stat + \
self.getUnitVal(words[i - 1]) + ',' + \
self.getUnitVal(words[i]) + ';'
- stat = stat + ']);'
+ stat = stat[:-1] + ']);'
modelicaCompInit.append(stat)
- if typ[0] == words[3] and typ[0] != "dc":
+ if typ[0] == words[3] and typ[0] != "dc" and typ[0] != "ac":
# It is DC constant but no dc keyword
val_temp = typ[0].split('v')
stat = self.mappingData["Sources"][sourceType]["dc"] + \
@@ -382,10 +382,17 @@ class NgMoConverter:
'(V = ' + \
self.getUnitVal(words[4]) + ');' # check this
modelicaCompInit.append(stat)
+ elif typ[0] == words[3] and typ[0] == "ac":
+ stat = self.mappingData["Sources"][sourceType][typ[0]] + \
+ ' ' + \
+ compName + \
+ '(V = ' + \
+ self.getUnitVal((words[4])) + ');'
+ modelicaCompInit.append(stat)
elif sourceType == 'i':
stat = self.mappingData["Sources"][sourceType]["dc"] + \
- ' ' + compName + '(I=' + self.getUnitVal(words[3]) + ');'
+ ' ' + compName + '(I=' + self.getUnitVal(words[4]) + ');'
modelicaCompInit.append(stat)
# Now empty the source list as it may be used by subcircuit
@@ -399,18 +406,10 @@ 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]
@@ -425,17 +424,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"]
@@ -452,11 +448,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"]
@@ -935,8 +934,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):
@@ -969,10 +968,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):