First time here? We are a friendly community of Power Systems Engineers. Check out the FAQ!
1 | initial version |
Here is something to get you started:
busno: use psspy.amachint
name: use psspy.amachchar
id: use psspy.amachchar
TEMPLATE = "CONTINGENCY %(name)s REMOVE MACHINE %(id)s FROM BUS %(num)s\n"
ierr, numbers = psspy.amachint(sid=-1) # machines at all buses
ierr, name_id = psspy.amachchar(sid=-1) # names and ids
# convert from columns to rows [(num, name, id), (num, name, id)]
num_name_id = zip(*(numbers + name_id))
confile = open("contingency.con", "wb")
for number, name, id in num_name_id:
confile.write(TEMPLATE % dict(name=name, id=id, number=num))
confile.close()
2 | Typo in my solution |
Here is something to get you started:
busno: use psspy.amachint
name: use psspy.amachchar
id: use psspy.amachchar
TEMPLATE = "CONTINGENCY %(name)s REMOVE MACHINE %(id)s FROM BUS %(num)s\n"
ierr, numbers = psspy.amachint(sid=-1) psspy.amachint(sid=-1, string=["NUMBER"]) # machines at all buses
ierr, name_id = psspy.amachchar(sid=-1) psspy.amachchar(sid=-1, string=["NAME", "ID"]) # names and ids
# convert from columns to rows [(num, name, id), (num, name, id)]
num_name_id = zip(*(numbers + name_id))
confile = open("contingency.con", "wb")
for number, name, id in num_name_id:
confile.write(TEMPLATE % dict(name=name, id=id, number=num))
number=number))
confile.close()