def get_chgl(self): dim = 2 num_gl_fields = dim M = 1.0 alpha = 0.1 dt = 0.001 gl_damping = M grad_coeff = [[alpha, 0.5 * alpha], [0.5 * alpha, alpha]] return PyCHGLRealSpace(dim, self.L, self.prefix, num_gl_fields, M, alpha, dt, gl_damping, grad_coeff)
def main(prefix, start, startfile, initfunc, dx=30.0, steps=0, update_freq=0): #prefix = "data/almgsi_chgl_random_seed_strain_noise2/chgl" #prefix = "data/almgsi_chgl_3D_surface_3nm_64_strain_meV/chgl" #prefix = "data/almgsi_chgl_3D_MLdx1_1nm_64_strain_meV/chgl" #prefix = "/work/sophus/almgsi_chgl_3D_MLdx1_3nm_64_strain_meV/chgl" dim = 3 L = 128 num_gl_fields = 3 M = 0.1 / dx**2 alpha = 5.0 dt = 0.003 gl_damping = M / dx**2 coeff, terms = get_polyterms(FNAME) poly = PyPolynomial(4) poly1 = PyPolynomial(1) with open(FNAME, 'r') as infile: info = json.load(infile) # kernel = PyGaussianKernel(info["kernel"]["std_dev"]) # regressor = PyKernelRegressor( # info["kernel_regressor"]["xmin"], # info["kernel_regressor"]["xmax"]) # regressor.set_kernel(kernel) # regressor.set_coeff(info["kernel_regressor"]["coeff"]) grad_coeff = info["gradient_coeff"] for item in info["terms"]: c = item["coeff"] powers = item["powers"] poly.add_term(c, PyPolynomialTerm(powers)) print(c, powers) N = len(info["conc_phase1"]) for i, c in enumerate(info["conc_phase1"]): poly1.add_term(c, PyPolynomialTerm([N - i - 1])) alpha = grad_coeff[0] / dx**2 b1 = grad_coeff[1] / dx**2 b2 = grad_coeff[2] / dx**2 #gradient_coeff = [[b2, b1, b2], # [b1, b2, b2], # [b2, b2, b1]] gradient_coeff = [[b1, b2, b1], [b2, b1, b1], [b1, b1, b2]] print(gradient_coeff) chgl = PyCHGLRealSpace(dim, L, prefix, num_gl_fields, M, alpha, dt, gl_damping, gradient_coeff) # landau = PyTwoPhaseLandau() # landau.set_polynomial(poly) # landau.set_kernel_regressor(regressor) # landau.set_discontinuity(info["discontinuity_conc"], info["discontinuity_jump"]) landau = PyQuadraticTwoPhasePoly() landau.set_poly_phase1(poly1) landau.set_poly_phase2(poly) chgl.set_free_energy_quadratic(landau) chgl.use_adaptive_stepping(1E-10, 1, 0.1) #chgl.set_field_update_rate(10) #chgl.set_strain_update_rate(100) chgl.build3D() add_strain(chgl) chgl.conserve_volume(1) if startfile is not None: chgl.from_file(prefix + startfile) else: if initfunc == "precipitate_square": chgl.from_npy_array(precipitates_square(L)) elif initfunc == "matsuda": chgl.from_npy_array(create_matsuda(L)) elif initfunc == 'prec_square_bck': chgl.from_npy_array(precipitate_square_bck(L)) else: raise ValueError("Unknown init function!") chgl.run(steps, update_freq, start=start) chgl.save_free_energy_map(prefix + "_free_energy_map.grid")
def main(): #prefix = "data/almgsi_chgl_random_seed_strain_noise2/chgl" prefix = "data/almgsi_chgl_3D_surface_1nm_64_strain_consistent/chgl" dx = 10.0 # Discretisation in angstrom dim = 3 L = 64 num_gl_fields = 3 M = 0.1 alpha = 5.0 dt = 1.0 gl_damping = M coeff, terms = get_polyterms(FNAME) poly = PyPolynomial(4) with open(FNAME, 'r') as infile: info = json.load(infile) kernel = PyGaussianKernel(info["kernel"]["std_dev"]) regressor = PyKernelRegressor(info["kernel_regressor"]["xmin"], info["kernel_regressor"]["xmax"]) regressor.set_kernel(kernel) regressor.set_coeff(info["kernel_regressor"]["coeff"]) grad_coeff = info["gradient_coeff"] for item in info["terms"]: c = item["coeff"] powers = item["powers"] poly.add_term(c, PyPolynomialTerm(powers)) print(c, powers) alpha = grad_coeff[0] / dx**2 b1 = grad_coeff[1] / dx**2 b2 = grad_coeff[2] / dx**2 gradient_coeff = [[b2, b1, b2], [b1, b2, b2], [b2, b2, b1]] print(gradient_coeff) chgl = PyCHGLRealSpace(dim, L, prefix, num_gl_fields, M, alpha, dt, gl_damping, gradient_coeff) landau = PyTwoPhaseLandau() landau.set_polynomial(poly) landau.set_kernel_regressor(regressor) landau.set_discontinuity(info["discontinuity_conc"], info["discontinuity_jump"]) chgl.set_free_energy(landau) #chgl.from_npy_array(precipitates_square(L)) chgl.use_adaptive_stepping(1E-10, 1, 0.05) chgl.build3D() add_strain(chgl) chgl.from_file(prefix + "00000053000.grid") chgl.run(500000, 5000, start=53000) chgl.save_free_energy_map(prefix + "_free_energy_map.grid")