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()
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()
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()
#!/bin/bash from datastore import InputDatastore from calcsim import CalcSimWrapper from numpy import * from scipy.optimize import * from expercomparison import ComparisonEngine from itertools import product ds = InputDatastore('../InputData', 'NiCu') x = linspace(0, 25, num=100) fedict = ds.edict_for_direction('forward') redict = ds.edict_for_direction('reverse') fexpr = ds.interpolated_experiment_dict(x, fedict) rexpr = ds.interpolated_experiment_dict(x, redict) diffusivity = ds.interpolated_diffusivity(1001, 973) resistivity = ds.interpolated_resistivity(1001, 973) cs = CalcSimWrapper() ce = ComparisonEngine(cs) initcond = ones(100) initcond[50:] = 0 dt = 0.05 ndt = int(2 * 60 * 60 / 0.05) dx = 25e-6 / 100 def make_objective(I, direction): if direction == 'forward': exprd = fexpr[I]
from calcsimexecutor import CalcSimExecutor from datastore import InputDatastore from pylab import * import defaults from expercomparison import ComparisonEngine 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))
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 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))
z_best = zrange[z_best_idx] z_plotlist.append(z_best) z_plotarr = np.array(z_plotlist) plotarr = np.column_stack((I_plotarr, z_plotarr)) outfname = os.path.join(args.outputdir, str.format("zplot_{}.png", direction)) dmplots.plot_z_function(plotarr, direction, outfname) # we should be nice and print comparison plots if direction == "forward" or direction == "reverse": x = np.linspace(0, 25, num=100) dstore = InputDatastore(args.inputdata, args.dataprefix) edict = dstore.edict_for_direction(direction) accelcs = CalcSimWrapper() ce = ComparisonEngine(accelcs) diffusivity = dstore.interpolated_diffusivity(10001, args.temperature, precise=True) resistivity = dstore.interpolated_resistivity(10001, args.temperature) init_cond = np.ones(100) init_cond[50:] = 0 emigration_T = args.temperature dt = 0.05 ndt = int(2 * 60 * 60 / 0.05) dx = 25e-6 / 100 for I in result_stash.keys(): cvf_best = cvfrange[result_stash[I][zaverage_index, :].argmin()] if direction == "forward": exper_data = dstore.interpolated_experiment_dict(x, edict)[I] r = accelcs.emigration_factor(zaverage_rounded, I * 100 * 100, emigration_T) else: exper_data = dstore.interpolated_experiment_dict(x, edict)[I] r = accelcs.emigration_factor(zaverage_rounded, -I * 100 * 100, emigration_T)