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()
Exemple #2
0
def quicksim(z, cvf, I, exper, direction):
    ce = ComparisonEngine(accelcs)
    if direction == 'reverse':
        I = -np.abs(I)
    else:
        I = np.abs(I)
    diffusivity = dstore.interpolated_diffusivity(10001, args.temperature, precise=True)
    resistivity = dstore.interpolated_resistivity(10001, args.temperature)
    r = accelcs.emigration_factor(z, I * 100 * 100, args.temperature)
    simd = accelcs.calc_simulation(diffusivity, resistivity, init_cond, ndt, dt, dx, r, cvf)
    lsq, shift = ce.calibrate(simd, exper)
    shifted_simd = ce.shift_data(simd)
    return shifted_simd, lsq
    def do_stage1(self):
        """Our stage 1 is to do the requested simulation and spit out a csv file with (x, sim, exper)
        """
        simexec = CalcSimExecutor(self.dstore, self.args.temperature)
        try:
            simdata = simexec.compute(self.args.z, self.args.cvf, self.args.current, self.args.direction)
        except SimulationUnstableError:
            print('Bang! Dmax = {}, Dmin = {}'.format(simexec.Dvector.max(), simexec.Dvector.min()))
            raise
        experdata = self.dstore.interpolated_experiment(self.args.current, simdata[:, 0], self.args.direction)

        ce = ComparisonEngine(CalcSimWrapper())
        ce.calibrate(simdata[:, 1], experdata)
        simdata[:, 1] = ce.shift_data(simdata[:, 1])

        self.fulldata = np.column_stack((simdata, experdata))

        self.ostore.add_matrix(self.fulldata, '.csv')
Exemple #4
0
for I in I_plot:
    ebars_list_lower.append(cbounds[I][0])
    ebars_list_upper.append(cbounds[I][2])
ebars = np.array([ebars_list_lower, ebars_list_upper])
plot_data = np.column_stack((I_plot, cvf_plot))
outfile = get_fname('cvfplot_combined.png')
dmplots.plot_cvf_function_ebars(plot_data, ebars, 'combined', outfile)

#and politely output simulations
cse = CalcSimExecutor(ds, T)
ce = ComparisonEngine(cse.cs)
x = linspace(0, 25, 100)
for direction in ('forward', 'reverse'):
    for I in cresults.keys():
        for idx, edge in ((0, 'lower'), (1, 'best'), (2, 'upper')):
            outfile = get_fname(str.format('Comparison_I{}_{}_{}bound.png', I, direction, edge))
            cvf = cbounds[I][1]
            if idx == 0:
                cvf -= cbounds[I][idx]
            elif idx == 2:
                cvf += cbounds[I][idx]
            print('using cvf = ' + str(cvf))
            edict = ds.edict_for_direction(direction)
            exper = ds.interpolated_experiment_dict(x, edict)[I]
            simd = cse.compute(zaverage_rounded, cvf, I, direction)
            exper = np.column_stack((x, exper))
            ce.calibrate(simd[:, 1], exper[:, 1])
            simd[:, 1] = ce.shift_data(simd[:, 1])
            f = dmplots.plot_sim_fit(simd, exper, I, zaverage_rounded, cvf, direction)
            c = FigureCanvasAgg(f)
            c.print_figure(outfile)
Exemple #5
0
I = 3000
cvfunc = lambda ID: 0.0014 * ID

ioff()
figure()
for T in (1000, 1100, 1200):
    Davg = dstore.interpolated_diffusivity(1001, T).mean()
    n_secs_sim = 1e-12 / Davg
    ndt = int(n_secs_sim / defaults.simulation_dt)
    cse = CalcSimExecutor(dstore, T)

    current_whole = cse.compute(z, cvfunc(I), I, "forward")
    nocurrent = cse.compute(0, 1, 0, "forward")[:, 1]

    x = current_whole[:, 0]
    current = current_whole[:, 1]

    shiftengine = ComparisonEngine(cse.cs)
    lsq, _ = shiftengine.calibrate(current, nocurrent)
    s_current = shiftengine.shift_data(current)

    plot(x, s_current, label="{}K, current".format(T))
    plot(x, nocurrent, label="{}K, no current".format(T))

xlabel("x coordinate (micron)")
ylabel("Cu concentration (at. fraction)")
title("Comparison of different Temps with correction")
legend(loc="lower left")

show()
Exemple #6
0
ylabel("Cu. Composition (at. fraction)")
title("Investigation of checkerboard")
subplot(212)
xlabel("Position (micron)")
ylabel(r"$\Delta$Cu Composition (at. fraction)")

for T in (1046, 1048, 1050, 1052):
    Davg = dstore.interpolated_diffusivity(1001, T).mean()
    n_secs_sim = 1e-12 / Davg
    dt = n_secs_sim / (defaults.simulation_tsteps * 1)
    cse = CalcSimExecutor(dstore, T, dt=dt, ndt=(defaults.simulation_tsteps * 1))

    simd_lc = cse.compute(z, cvfunc(2600), 2600, "forward")
    simd_hc = cse.compute(z, cvfunc(2700), 2700, "forward")

    shiftengine = ComparisonEngine(cse.cs)
    shiftengine.calibrate(simd_lc[:, 1], simd_hc[:, 1])
    simd_lc[:, 1] = shiftengine.shift_data(simd_lc[:, 1])

    subplot(211)
    plot(simd_lc[:, 0], simd_lc[:, 1], label="T = {}K, I = {}A/cm^2".format(T, 2600))
    plot(simd_hc[:, 0], simd_hc[:, 1], label="T = {}K, I = {}A/cm^2".format(T, 2700))
    subplot(212)
    plot(simd_lc[:, 0], simd_hc[:, 1] - simd_lc[:, 1], label="T = {}K".format(T))

subplot(211)
legend(loc="best")
subplot(212)
legend(loc="best")
savefig("../checkerboard_investigation.png")
Exemple #7
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))