Exemple #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()
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))
Exemple #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()
    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()
Exemple #5
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()
Exemple #6
0
aparser.add_argument('--inputdata', metavar='DIR', type=str, required=True,
                     help='Directory containing input data')
aparser.add_argument('--dataprefix', metavar='PREFIX', type=str, default='NiCu',
                     help='Prefix to data files')
aparser.add_argument('--output', metavar='FILE', type=str, required=True,
                     help='File to output to')
aparser.add_argument('--z', type=float, required=True,
                     help='Effective valence')
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
Exemple #7
0
    help="Limits of the effective valence search (up to but not including ZMAX)",
)
aparser.add_argument(
    "--cvflim",
    metavar=("CVFMIN", "CVFMAX", "CVFSTEP"),
    nargs=3,
    type=float,
    required=True,
    help="Limits of the vacancy concentration multiplier search (up to but not including CVFSTEP)",
)
aparser.add_argument("--resume", action="store_true", default=False, help="Resume using .csv files in outputdir")

args = aparser.parse_args()

dstore = InputDatastore(args.inputdata, args.dataprefix)
accelcs = CalcSimWrapper()

zrange = np.arange(args.zlim[0], args.zlim[1], args.zlim[2])
cvfrange = np.arange(args.cvflim[0], args.cvflim[1], args.cvflim[2])

fresults = dict()
rresults = dict()

np.savetxt(path.join(args.outputdir, "zrange.csv"), zrange, delimiter=",")
np.savetxt(path.join(args.outputdir, "cvfrange.csv"), cvfrange, delimiter=",")

if args.resume:
    files = [
        path.join(args.outputdir, f) for f in os.listdir(args.outputdir) if path.isfile(path.join(args.outputdir, f))
    ]
    forwardfiles = [f for f in files if f.endswith("forward.csv")]