def compute_dimensionless_ch_params_from_polymer_params( X, N, L_omega, L_kuhn, m): eps_2 = ch.CHparamsVector().compute_eps2_from_polymer_params( X, m, L_kuhn, L_omega, N) sigma = ch.CHparamsVector().compute_sigma_from_polymer_params( X, m, L_kuhn, L_omega, N) return eps_2, sigma
def setup_chparams(info: ch.SimInfo, p: Dict[str, float]) -> ch.CHparamsVector: """ inputs: info : instance of ch.SimInfo p : dict of mc material parameters, e.g. produced by MaterialParamsUniformDistribution::draw() """ eps_2, sigma = compute_dimensionless_ch_params_from_polymer_params( X=p['X'], N=p['N'], L_omega=p['L_omega'], L_kuhn=p['L_kuhn'], m=p['m']) chparams = ch.CHparamsVector(int(info.nx), int(info.ny)) nx = int(info.nx) xx, yy = np.meshgrid(np.arange(0, 1, 1 / info.nx), np.arange(0, 1, 1 / info.nx)) chparams.eps_2 = ch.DoubleVector(eps_2 * np.ones(nx**2)) chparams.sigma = ch.DoubleVector(sigma * np.ones(nx**2)) chparams.m = ch.DoubleVector(p['m'] * np.ones(nx**2)) return chparams
info = ch.SimInfo() info.t0 = 0.0 info.nx = 128 info.ny = 128 info.dx = 1. / info.nx info.dy = 1. / info.ny info.bc = 'neumann' info.rhs_type = 'ch_thermal_no_diffusion' # Set up grid for spatial-field quantities nx = int(info.nx) xx, yy = np.meshgrid(np.arange(0, 1, 1 / info.nx), np.arange(0, 1, 1 / info.nx)) # Setup CH parameter info object chparams = ch.CHparamsVector(info.nx, info.ny) chparams.b = ch.DoubleVector(1.0 * np.ones(nx**2)) chparams.u = ch.DoubleVector(1.0 * np.ones(nx**2)) chparams.m = ch.DoubleVector(0.0 * np.ones(nx**2)) chparams.sigma_noise = 0.0 chparams.eps2_min = 0.0 chparams.eps2_max = 1.0 chparams.sigma_min = 0.0 chparams.sigma_max = 1.0e10 chparams.T_min = 0.1 chparams.T_max = 1.0 chparams.T_const = ch.DoubleVector(chparams.T_max * np.ones(nx**2)) chparams.L_kuhn = L_kuhn chparams.N = N chparams.L_omega = L_omega chparams.X_min = Xmin
import numpy as np import matplotlib.pyplot as plt from scipy import misc import cahnhilliard as ch chparams = ch.CHparamsVector() info = ch.SimInfo() # *********** INPUTS *********** info.t0 = 0.0 info.nx = 128 info.ny = 128 info.dx = 1. / info.nx info.dy = 1. / info.ny info.bc = 'periodic' info.BC_dirichlet_ch = 1.0 nx_ref = 128 dx_ref = 1. / nx_ref eps_2 = 0.01**2 sigma = eps_2 / dx_ref**4 / 200. b = eps_2 / dx_ref**2 u = eps_2 / dx_ref**2 m = 0.0 sigma_noise = 0.0 DT = 0.1 * eps_2 / dx_ref**2 # Set up grid for spatial-field quantities nx = int(info.nx) xx, yy = np.meshgrid(np.arange(0, 1, 1 / info.nx),
def convert_temperature_to_flory_huggins(T, Tmin, Tmax, Xmin, Xmax): assert ((T > 1e-5) & (Tmin > 1e-5)) return ch.CHparamsVector().convert_temperature_to_flory_huggins( T, Tmin, Tmax, Xmin, Xmax)