def __init__(self, config): self.cfg = config self.verbose = self.cfg.get("general.verbose") self.time_period = self.cfg.get("time.time_period") self.delta_t = self.cfg.get("time.dt") self.timesteps = int((self.time_period * (1.0 + self.delta_t * 1e-6)) // self.delta_t) self.times = np.linspace(0, self.time_period, self.timesteps + 1) # set correct delta_t self.delta_t = self.times[1] - self.times[0] if self.verbose: print "Timestep used in bednet model:", self.delta_t self.initconc = self.cfg.get("initial.init_conc") self.dx = self.cfg.get("domain.dx") self.dy = self.cfg.get("domain.dy") self.nvertyarns = self.cfg.get("domain.nr_vert_yarns") self.nhoryarns = self.cfg.get("domain.nr_hor_yarns") self.diff_coef = self.cfg.get("diffusion.diff_coef") self.saturation_conc = self.cfg.get("active_component.saturation_conc") self.treshold = self.cfg.get("active_component.treshold_effect") x0 = self.cfg.get("observer.x0") self.x0 = np.empty(len(x0) + 1, float) self.x0[1:] = x0[:] # we set a distance for the yarn bc EXTFRAC = 1.0 self.cfg_yarn = [] for filename in self.cfg.get("sample.yarn_config"): if not os.path.isabs(filename): filename = os.path.normpath(os.path.join(os.path.dirname(self.cfg.filename), filename)) self.cfg_yarn.append(YarnConfigManager.get_instance(filename)) # set values from the yarn on this inifile print "time", self.time_period self.cfg_yarn[-1].set("time.time_period", self.time_period) self.cfg_yarn[-1].set("boundary.dist_conc_out", float(self.x0[0])) self.cfg_yarn[-1].set("boundary.D_out", self.diff_coef) self.cfg_yarn[-1].set("boundary.conc_out", self.initconc) self.cfg_yarn[-1].set("domain.useextension", True) ##TODO How much overlap region? Take one yarn radius for now self.cfg_yarn[-1].set("domain.extensionfraction", EXTFRAC) radyarn = self.cfg_yarn[-1].get("domain.yarnradius") for conf in self.cfg_yarn: assert radyarn == self.cfg_yarn[-1].get("domain.yarnradius") # we need concentration at half of the extra zone self.x0[0] = radyarn + EXTFRAC * radyarn / 2 self.overlapsize = EXTFRAC * radyarn self.overlaparea = np.pi * (np.power(radyarn + self.overlapsize, 2) - np.power(radyarn, 2)) # create yarn models self.yarn_models = [] for cfg in self.cfg_yarn: self.yarn_models.append(Yarn1DModel(cfg)) self.nr_models = len(self.yarn_models) # some memory self.source_mass = np.empty((self.nr_models, self.timesteps + 1), float) # plot the result every few seconds so outcome becomes visible during calculations self.plotevery = self.cfg.get("plot.plotevery")
radius_pure_fiber = 0.05441 form = 'ellipse' eccentricity = 0.7 nrlayers = 2 mean_deviation = 0.0 [fiberlayer_0] thickness = 0.001 [fiberlayer_1] thickness = 0.001 [plot] plotevery = 10 """ from stick.fiber.config import FiberConfigManager from stick.yarn.config import YarnConfigManager from stick.lib.utils.utils import set_outputdir cfgf1 = FiberConfigManager.get_instance('tmpfiber1.ini', realdatastr=ini_fiber1) cfgf2 = FiberConfigManager.get_instance('tmpfiber2.ini', realdatastr=ini_fiber2) cfg = YarnConfigManager.get_instance('tmpyarn.ini', realdatastr=ini_yarn) if not os.path.isdir('temp'): os.mkdir('temp') set_outputdir('temp') #create a 2D grid for simulate DEET diffusion process from stick.yarn2d.yarn2dmodel import Yarn2DModel Yarn2DModel(cfg) print 'calculate DEET diffusion' raw_input('Press key to quit the calculation')
def __init__(self, config): # indicate if only one side of bednet is free, or both are free self.singleside = False # other settings from config self.cfg = config self.verbose = self.cfg.get("general.verbose") self.time_period = self.cfg.get("time.time_period") self.delta_t = self.cfg.get("time.dt") self.timesteps = int((self.time_period * (1.0 + self.delta_t * 1e-6)) // self.delta_t) # set correct delta_t self.delta_t = self.time_period / self.timesteps if self.verbose: print("Timestep used in bednet model:", self.delta_t) self.initconc = eval(self.cfg.get("initial.init_conc")) self.dx = self.cfg.get("domain.dx") self.dy = self.cfg.get("domain.dy") # size room in mm self.room_L = self.cfg.get("domain.room_L") * 1000 self.room_W = self.cfg.get("domain.room_W") * 1000 self.room_H = self.cfg.get("domain.room_H") * 1000 self.nvertyarns = self.room_W / self.dx self.nhoryarns = self.room_H / self.dy self.diff_coef = self.cfg.get("diffusion.diff_coef") self.saturation_conc = self.cfg.get("active_component.saturation_conc") self.treshold = self.cfg.get("active_component.treshold_effect") self.x0 = self.cfg.get("observer.x0") # define whether there is the ventilation existing self.ventilation = self.cfg.get("domain.ventilation") self.vel_ventilation = self.cfg.get("domain.vel_ventilation") # we set a distance for the yarn bc EXTFRAC = 1.0 self.cfg_yarn = [] self.radius_yarn = [] for filename in self.cfg.get("sample.yarn_config"): if not os.path.isabs(filename): filename = os.path.normpath(os.path.join(os.path.dirname(self.cfg.filename), filename)) self.cfg_yarn.append(YarnConfigManager.get_instance(filename)) # set values from the yarn on this inifile print("time", self.time_period) self.cfg_yarn[-1].set("time.time_period", self.time_period) self.cfg_yarn[-1].set("boundary.dist_conc_out", float(self.x0[0])) self.cfg_yarn[-1].set("boundary.D_out", self.diff_coef) self.cfg_yarn[-1].set("boundary.conc_out", float(self.initconc(self.cfg_yarn[-1].get("domain.yarnradius")))) self.cfg_yarn[-1].set("domain.useextension", True) ## How much overlap region? Take one yarn radius for now self.cfg_yarn[-1].set("domain.extensionfraction", EXTFRAC) self.radius_yarn.append(self.cfg_yarn[-1].get("domain.yarnradius")) assert self.radius_yarn[-1] == self.radius_yarn[0], ( "ERROR, yarns" " must have equal radius for now, as massperyarn is equally " "distributed over the yarns" ) # we want the overlap zone of the yarns to end at 2* maximum radius: self.maxyarnrad = max(self.radius_yarn) self.minyarnrad = min(self.radius_yarn) voloverlapyarn = ( np.pi * ((self.maxyarnrad * (1 + EXTFRAC)) ** 2 - (self.maxyarnrad ** 2)) * (self.nhoryarns * self.room_W + self.nvertyarns * self.room_H) ) # self.endoverlap = self.maxyarnrad * (1 + EXTFRAC) if self.singleside: self.endoverlap = self.minyarnrad + voloverlapyarn / self.room_W / self.room_H else: self.endoverlap = self.minyarnrad + voloverlapyarn / self.room_W / self.room_H / 2 for config, rad in zip(self.cfg_yarn, self.radius_yarn): config.set("domain.extensionfraction", EXTFRAC) # create yarn models self.yarn_models = [] for cfg in self.cfg_yarn: self.yarn_models.append(Yarn1DModel(cfg)) self.nr_models = len(self.yarn_models) # some memory self.source_mass = np.empty(self.nr_models, float) # self.mass_build = [0.,] # plot the result every few seconds so outcome becomes visible during calculations self.plotevery = self.cfg.get("plot.plotevery") self.viewerwritecount = 0 self.writeevery = self.cfg.get("plot.writeevery") # now some output on density self.volbednet = 0.0 self.surfbednet = self.room_H * self.room_W for rad in self.radius_yarn: print("vert vol yarns", self.nvertyarns * pi * rad ** 2 * self.room_H, "mm3") print("horz vol yarns", self.nhoryarns * pi * rad ** 2 * self.room_W, "mm3") self.volbednet += self.nvertyarns * pi * rad ** 2 * self.room_H self.volbednet += self.nhoryarns * pi * rad ** 2 * self.room_W print("volume_bednet space =", (2 * self.maxyarnrad * self.room_H * self.room_W)) # The total volume of the bednet incl void space is the area of the # net * the tickness of the net. # This thickness is taken to be twice a yarndiameter. self.totalvolume_net = self.room_H * self.room_W * 4 * self.maxyarnrad self.voidvolume = self.totalvolume_net - self.volbednet self.densitybednet = self.volbednet / (2 * self.maxyarnrad * self.room_H * self.room_W) self.fabporosity = self.voidvolume / self.totalvolume_net self.initialized = False self.yarnconc_center = np.empty((self.timesteps, 2), float) self.yarnconc_surface = np.empty((self.timesteps, 2), float)