Ejemplo n.º 1
0
def do_work(T, I):
    with dstorelock:
        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))

    try:
        current = cse.compute(z, cvfunc(I), I, direction)[:, 1]
        nocurrent = cse.compute(0, 1, 0, direction)[:, 1]
    except SimulationUnstableError:
        print('F****d up on T = {}, I = {}'.format(T, I))
        print('Max D = {}'.format(cse.Dvector.max()))
        raise
    shiftengine = ComparisonEngine(cse.cs)
    lsq, _ = shiftengine.calibrate(current, nocurrent)
    return lsq
Ejemplo n.º 2
0
    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')
Ejemplo n.º 3
0
#matplotlib.rcParams['svg.fonttype'] = 'none'
matplotlib.rcParams['axes.labelsize'] = 24
matplotlib.rcParams['legend.fontsize'] = 22
matplotlib.rcParams['xtick.labelsize'] = 20
matplotlib.rcParams['ytick.labelsize'] = 20

def get_edict(x):
    return ds.interpolated_experiment_fw_dict(x) if direction == 'forward' else ds.interpolated_experiment_rv_dict(x)

figure()
cse = CalcSimExecutor(ds, T)
colours = ['#0000FF', '#FF0000', '#003300', '#DD8500']
colours.reverse()
for I, sh in [[0, 0], [400, 0], [800, 0], [1000, 0]]:
    cvf = 0.53e-3 * I + 1
    simd = cse.compute(z, cvf, I, direction)
    x = simd[:, 0]
    edict = get_edict(x)
    expr = edict[I]
    shifter = ComparisonEngine(cse.cs)
    shifter.calibrate(simd[:, 1], expr)
    #simd[:, 1] = shifter.shift_data(simd[:, 1])

    x += sh
    cl = colours.pop()
    #plot(x, expr, linestyle='-', label='I = {}A/cm^2'.format(I))
    plot(x, simd[:, 1], linestyle='-', color=cl, linewidth=2, label=r'$\mathrm{'+str(I)+'A/cm}^2$')

xlim([5, 20])
xticks(arange(5, 21, 5))
xlabel('Position (micron)')
Ejemplo n.º 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)
Ejemplo n.º 5
0
dstore = InputDatastore("../InputData", "NiCu")

z = 1875
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")
Ejemplo n.º 6
0
figure(figsize=(11, 7.7))
subplot(211)
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)