#!/usr/bin/env python # CORBA python implementation of Ni-NiO calculator # Victor Kress, Paris 7/3/2003 # modified 6/18/04 to offload ugly stuff to dPhaseClientUtils # $Id: NNO.py,v 1.23 2007/09/19 21:26:45 kress Exp $ import sys import Connection from phases import dPhase from omniORB import CORBA con=Connection.Connection() print 'orb gotten' pFactory = con.getdPhaseFactory() print 'dPhaseFactoryGotten' cd = con.getClientData() #for debugging print con.orb.object_to_string(pFactory) # Everything up to now is required to contact server and get # phase factory. Now we are ready to spawn phase objects #print 'spawning objects' try: nmet=pFactory.spawnPhase('NiMet',cd) o2gas=pFactory.spawnPhase('O2Gas',cd) nio=pFactory.spawnPhase('Bunsenite',cd) except CORBA.Exception, ex: print "Error in spawning Phase object:\n\t", print ex sys.exit(1) if nmet is None: print "Null object returned from spawning NiMetal" if o2gas is None: print "Null object returned from spawning O2Gas" if nio is None: print "Null object returned from spawning Bunsenite" # We now have everything we need to do calculations ######### r=8.314472 print 'CORBA client to calculate log10(fO2) at T for Ni-NiO assemblage.' while 1: tk = input('Input temperature in C: ') tk += 273.15 try: nmet.setTk(tk) o2gas.setTk(tk) nio.setTk(tk) except dPhase.PhaseError, ex: print ex else: break rtlnfo2 = 2.*nio.getG() - 2.*nmet.getG() - o2gas.getG() logfo2 = rtlnfo2/(2.3026*r*tk) print 'log10(fO2) at %6.1f C = %6.2f' % (tk-273.15,logfo2) # Everything from here on is cleanup. # ALL objects must be manually removed, even in garbage collected languages # such as Python or Java. Failure to do this will result in accumulation of # live but unused objects on the server. These will be cleaned up eventually, # but they add to server overhead. #print 'cleaning up' o2gas.remove() nmet.remove() nio.remove()