def Simulate(): record_path = '/Users/matthewbakalar/projects/VASP/latticerecord2.dat' simulation_steps = 100 initial_size = 10 max_size = 10000 c_steps = 10 c_multiplier = 10 c_range = sp.zeros(c_steps) c_range[0] = .0001 for i in range(1,c_steps): c_range[i] = c_range[i-1] * c_multiplier error = sp.zeros(c_range.size) a = sp.zeros(c_range.size) b = sp.zeros(c_range.size) count = 0 for conc in c_range: lattice = LatticeModel(initial_size, max_size) simulation = VaspSimulation(lattice) record = SimulationRecord(record_path, simulation, 'w') record.open_file() VaspSimulation.VASP_ON = VaspSimulation.VASP_ON_BASE * conc for i in range(0, simulation_steps): simulation.advance_simulation() record.save_state() record.close_file() record = SimulationRecord(record_path, simulation, 'r') time_recon = TimeReconstruction(record) lvt = time_recon.length_vs_time() #Linear regressison -polyfit - polyfit can be used other orders polys n = lvt[0].size (ar,br)=polyfit(lvt[0],lvt[1],1) xr=polyval([ar,br],lvt[0]) #compute the mean square error err=sp.sqrt(sum((xr-lvt[1])**2)/n) print('Linear regression using polyfit') print('parameters: regression: a=%.2f b=%.2f, ms error= %.3f' % (ar,br,err)) pyplot.plot(lvt[0], lvt[1], 'g') pyplot.plot(lvt[0], xr, 'r') pyplot.show() a[count] = ar b[count] = br error[count] = err count+=1 print 'Count = %(count)d' % {'count':count}
def Simulate(): for sim, fname in Experiment.runs: Experiment.Log('Starting: ' + fname) for conc in Experiment.conc: Experiment.Log('Concentration: ' + str(conc)) fname_conc = fname + '_c=' + str(conc) pth = os.path.join(Experiment.datafolder, fname_conc) record = SimulationRecord(pth, sim, 'w') record.open_file() VaspSimulation.VASP_ON = VaspSimulation.VASP_ON_BASE * conc while sim.time <= Experiment.equilibrate: sim.advance_simulation() sim.time = 0 while sim.time <= Experiment.simulate: if sim.time % 1 < 0.01: Experiment.Log('Time: ' + str(sim.time)) sim.advance_simulation() record.save_state() record.close_file()