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()
#!/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]
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 = path.join(args.outputdir, 'cvfplot_combined.png') print(I_plot) print(ebars) dmplots.plot_cvf_function_ebars(plot_data, ebars, 'combined', outfile) #and politely output simulations for direction in ('forward', 'reverse'): for I in cresults.keys(): for idx, edge in ((0, 'lower'), (1, 'best'), (2, 'upper')): outfile = path.join(args.outputdir, 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 = dstore.edict_for_direction(direction) exper = dstore.interpolated_experiment_dict(x, edict)[I] simd, lsq = quicksim(zaverage_rounded, cvf, I, exper, direction) simd = np.column_stack((x, simd)) exper = np.column_stack((x, exper)) f = dmplots.plot_sim_fit(simd, exper, I, zaverage_rounded, cvf, direction) c = FigureCanvasAgg(f) c.print_figure(outfile)
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 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))