Git Product home page Git Product logo

pyoc's Introduction

pyoc

Python interface to OpenCalphad

Author:

Installation

Recommended - installation via pip:

pip install pyoc

Installation from source is the same as for other python modules.

python setup.py install

Example:

from pyoctq import tqini, tqrfil, tqgpn, tqsetc, tqce, tqgetv, ctuple, cname, cnel
import numpy as np
import pyoctq as tq

n = 0
xf = np.array([.5,.5])
pxf = np.zeros((10,),dtype=np.double)
mu = np.zeros((10,),dtype=np.double)
phnames = [""]
tqini(n)
tqrfil('FENI.TDB')
formatter = "System with %i elements: " 
print formatter % cnel() +str([ cname(i) for i in range(0,cnel()) ])
print "and %i phases: " % ctuple()
phnames = [""]
for i in range(1,ctuple()+1):
    phnames.insert(i, tqgpn(i))
print phnames[1:]
n1 = 0
n2 = 0
# numerical values of conditions T, P, N
tp = [1e3,1e5,1.]
# set conditions for temperature, pressure and amount
cond = ["T", "P", "N"]
cnum = []
cnum.append(tqsetc(cond[0], n1,n2, tp[0]))
cnum.append(tqsetc(cond[1], n1, n2, tp[1]))
cnum.append(tqsetc(cond[2], n1, n2, tp[2]))
#for i in range(1,3):
#    xf[i] = 1.0/2.0

for i in range(1,2):
    cond = "X"
    cnum.append(tqsetc(cond,i,n2,xf[i]))
# calculate equilibria
target = " "
n1 = 0
n2 = 0
value = .0
tqce(target, n1, n2, value) 
statvar = "NP"
npf = np.array([0.1,0.2,0.3,0.5])
n1 = -1
n2 = 0
stable_ph = tqgetv(statvar,n1,n2, npf.size, npf)
print "Amount of %i phases:" % (stable_ph)
for i in npf[:stable_ph]:
    print "%.9f" % i

for i in range(1, ctuple()+1):
    print "Phase : %s " % phnames[i]
    if npf[i] > 0.0:
        print "Stable phase : %s, amount: %lf" % (phnames[i], npf[i])
        # use phase tuple index i
        statvar = "X"
        n2 = -1
        n4 = tqgetv(statvar, i, n2, pxf.size, pxf)
        for k in range(0,n4):
            print " %s : %lf, " % (cname(k), pxf[k])

print "Component, mole fraction and chemical potential"
for i in range(1, cnel()+1):
    statvar = "MU"
    n2 = 0
    n4 = pxf.size
    tqgetv(statvar, i, n2, n4, pxf)
    mu[i] = pxf[0]
    statvar = "X"
    tqgetv(statvar, i, n2, n4, pxf)
    print "%s        %lf        %lf" % (cname(i-1), pxf[0], mu[i]) 

=======

This is Open Calphad version 4+

pyoc's People

Contributors

sundmanbo avatar richardotis avatar teslos avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.