예제 #1
0
def plot_for(z, d):
    cs = CalcSimWrapper()
    ds = InputDatastore('../InputData', 'NiCu', 973)
    ce = ComparisonEngine(cs)
    D = ds.interpolated_diffusivity(10001)
    R = ds.interpolated_resistivity(10001)

    dx = 0.5 * 35e-8
    ndx = 200
    dt = 0.01
    ndt = int(2 * 60 * 60 / 0.01)

    init = ones(ndx)
    init[ndx/2:] = 0

    x = linspace(0, 25, 200)

    ddict = ds.interpolated_experiment_dict(x)

    for I in ddict.keys():
        if I == 0:
            dv = 1
        else:
            dv = d
        r = cs.emigration_factor(z, I, 973)
        mdl = cs.calc_simulation(D, R, init, ndt, dt, dx, r, dv)
        ce = ComparisonEngine(cs)
        lsq, shfit = ce.calibrate(mdl, ddict[I])
        smdl = ce.shift_data(mdl)
        plot(x, ddict[I], label=str.format('Exper. (I={} A/cm^2)', I/100/100))
        plot(x, smdl, label=str.format('Model. (I={} A/cm^2)', I/100/100))

    legend(loc=3)
    show()
예제 #2
0
class CalcSimExecutor():

    def __init__(self, dstore, T, ndt=defaults.simulation_tsteps, dt=defaults.simulation_dt):
        assert isinstance(dstore, InputDatastore)

        self.T = T

        #first, get defaults
        self.dx = defaults.simulation_dx
        self.dt = dt
        self.ndx = defaults.simulation_xsteps
        self.ndt = ndt

        #now we can set up the initial conditions
        #x in micron
        self.x = np.arange(0, self.ndx * self.dx, self.dx) * 1e6
        self.init_cond = np.ones(self.ndx)
        self.init_cond[(self.ndx // 2):] = 0

        #D/R vectors
        self.Dvector = dstore.interpolated_diffusivity(10001, T, precise=False).copy()
        self.Rvector = dstore.interpolated_resistivity(10001, T).copy()

        self.cs = CalcSimWrapper()
        #now we're ready to fire on demand

    def compute(self, z, cvf, I, direction):
        """
        Actually runs the simulation that's been set up, with the supplied
        parameters. I is supplied in A/cm^2
        Returns sim results as a 2 column array of x, y
        """

        if direction == 'forward':
            pass
        elif direction == 'reverse':
            I = -I
        else:
            raise ValueError('Unknown direction ' + str(direction))

        r = self.cs.emigration_factor(z, I * 100 * 100, self.T)
        outy = self.cs.calc_simulation(self.Dvector, self.Rvector, self.init_cond,
                                       self.ndt, self.dt, self.dx, r, cvf)
        return np.column_stack((self.x, outy))
예제 #3
0
def basic_test():
    cs = CalcSimWrapper()
    ds = InputDatastore('../InputData', 'NiCu', 973)
    ce = ComparisonEngine(cs)

    D = ds.interpolated_diffusivity(10001)
    R = ds.interpolated_resistivity(10001)

    dx = 0.5*35e-8
    ndx = 200
    dt = cs.optimum_dt(dx, D, 1)
    ndt = cs.num_sim_steps(dt, 2 * 60 * 60)

    init = np.ones(ndx)
    init[ndx/2:] = 0

    res = cs.calc_simulation(D, R, init, ndt, dt, dx, 0, 1)
    res = cs.calc_simulation(D, R, init, ndt, dt, dx, 0, 1)
    x = np.linspace(0, dx * ndx, num=ndx)
    plot(x, res)
    show()
예제 #4
0
from calcsim import CalcSimWrapper
from datastore import InputDatastore
import numpy as np
from pylab import *

ds = InputDatastore('../InputData', 'NiCu', 973)
cs = CalcSimWrapper()

D = ds.interpolated_diffusivity(10001)
R = ds.interpolated_resistivity(10001)

dx = 0.5*35e-8
ndx = 200
dt = cs.optimum_dt(dx, D, 1)
ndt = cs.num_sim_steps(dt, 2 * 60 * 60)

init = np.ones(ndx)
init[ndx/2:] = 0

res = cs.calc_simulation(D, R, init, ndt, dt, dx, 0, 1)
x = np.linspace(0, dx * ndx, num=ndx)
plot(x, res)
show()
예제 #5
0
aparser.add_argument('--cvf', type=float, required=True,
                     help='Vacancy concentration factor')
aparser.add_argument('--direction', type=str, default='forward',
                     help='Direction of application of current')

args = aparser.parse_args()

accelcs = CalcSimWrapper()
dstore = InputDatastore(args.inputdata, args.dataprefix, 973, args.direction)
ce = ComparisonEngine(accelcs)

x = np.linspace(0, 25, num=100)
exper_data = dstore.interpolated_experiment_dict(x)[args.current]
diffusivity = dstore.interpolated_diffusivity(10001)
resistivity = dstore.interpolated_resistivity(10001)
init_cond = np.ones(100)
init_cond[50:] = 0

emigration_T = 973
dt = 0.05
ndt = int(2 * 60 * 60 / 0.05)
dx = 25e-6 / 100

r = accelcs.emigration_factor(args.z, args.current * 100 * 100, emigration_T)
simd = accelcs.calc_simulation(diffusivity, resistivity, init_cond, ndt, dt, dx, r, args.cvf)
lsq, shift = ce.calibrate(simd, exper_data)
shifted_simd = ce.shift_data(simd)
full_simd = np.column_stack((x, shifted_simd))
full_exper = np.column_stack((x, exper_data))
dmplots.plot_sim_fit(full_simd, full_exper, args.current, args.z, args.cvf, args.direction, args.output)
print('lsq = ' + str(lsq))