def underloop(name, r_key): jou = pj.Journal() jou.file.read_case.set('../../../cas/start.cas') jou.file.mesh_replace.set(f'../../../msh/FLAT-{name}.msh') jou.define.models.viscous.set(model) if model in ['ke-standard', 'ke-rng', 'ke-realizable']: if wall_function == 'standard': jou.define.models.viscous.near_wall_treatment.set('enhanced-wall-treatment') jou.define.models.viscous.near_wall_treatment.set('enhanced-wall-treatment no') else: jou.define.models.viscous.near_wall_treatment.set(wall_function) jou.solve.monitors.residual.convergence_criteria.set(1e-6) jou.surface.line_surface.set('cut-1', .1, 0, .1, .005) jou.surface.line_surface.set('cut-2', .9, 0, .9, .005) jou.define.boundary_conditions.velocity_inlet.set('inlet', Helper.reynolds.get(r_key), 300) jou.define.boundary_conditions.pressure_outlet.set('outlet', 300) jou.define.boundary_conditions.wall.set('wall', 1000) jou.define.boundary_conditions.wall.set('wall-out', 1000) jou.solve.initialize.compute_defaults.velocity_inlet.set('inlet') jou.solve.initialize.initialize_flow.set() jou.solve.iterate.set(iters) jou.report.surface_integrals.area.set(f'../../../out/out-{name}.txt', 'wall') jou.report.fluxes.heat_transfer.set(f'../../../out/out-{name}.txt', 'wall') jou.report.surface_integrals.facet_avg.set(f'../../../out/out-{name}.txt', 'temperature', 'axis') jou.report.surface_integrals.facet_avg.set(f'../../../out/out-{name}.txt', 'pressure', 'cut-1', 'cut-2') jou.file.write_case_data.set(f'../../../cas/{name}.cas') jou.save(f'../../../cls/cmd-{name}.jou')
def underloop(name, r_key): jou = pj.Journal() jou.file.read_case.set('../../../cas/start.cas') jou.file.mesh_replace.set(f'../../../msh/{name}.msh') jou.define.models.viscous.set(model) if model in ['ke-standard', 'ke-rng', 'ke-realizible']: if wall_function == 'standard': jou.define.models.viscous.near_wall_treatment.set('enhanced-wall-treatment') jou.define.models.viscous.near_wall_treatment.set('enhanced-wall-treatment no') else: jou.define.models.viscous.near_wall_treatment.set(wall_function) jou.solve.monitors.residual.convergence_criteria.set(1e-6) for point, (x, y) in test_points.items(): jou.surface.point_surface.set(point, x, y) jou.define.boundary_conditions.velocity_inlet.set('inlet', Helper.reynolds.get(r_key), 300) jou.define.boundary_conditions.pressure_outlet.set('outlet', 300) jou.define.boundary_conditions.wall.set('wall-fluid', 1000) jou.define.boundary_conditions.wall.set('wall-solid', 1000, False) jou.solve.initialize.compute_defaults.velocity_inlet.set('inlet') jou.solve.initialize.initialize_flow.set() jou.solve.iterate.set(iters) jou.report.fluxes.mass_flow.set(f'../../../out/out-{name}.txt', 'inlet', 'outlet') jou.report.fluxes.heat_transfer.set(f'../../../out/out-{name}.txt', 'wall-fluid', 'wall-solid', 'inlet', 'outlet') jou.report.surface_integrals.facet_avg.set(f'../../../out/out-{name}.txt', 'temperature', ' '.join(list(test_points.keys()))) jou.report.surface_integrals.facet_avg.set(f'../../../out/out-{name}.txt', 'pressure', 'inlet', 'outlet') jou.file.write_case_data.set(f'../../../cas/{name}.cas') jou.save(f'../../../cls/cmd-{name}.jou')
def solve_flat(self, **kwargs): prefixes = self._kwarg_parse(kwargs.get('prefixes'), [None]) suffixes = self._kwarg_parse(kwargs.get('suffixes'), [None]) iters = self._kwarg_parse(kwargs.get('iters'), 1e3) model = self._kwarg_parse(kwargs.get('model'), 'kw-sst') wall_function = self._kwarg_parse(kwargs.get('wall_function'), 'enhanced-wall-treatment') criteria = self._kwarg_parse(kwargs.get('criteria'), 1e-6) self.job = 'solve' if not self.local: self._cluster() def underloop(name, r_key): jou = pj.Journal() jou.file.read_case.set('../../../cas/start.cas') jou.file.mesh_replace.set(f'../../../msh/FLAT-{name}.msh') jou.define.models.viscous.set(model) if model in ['ke-standard', 'ke-rng', 'ke-realizable']: if wall_function == 'standard': jou.define.models.viscous.near_wall_treatment.set('enhanced-wall-treatment') jou.define.models.viscous.near_wall_treatment.set('enhanced-wall-treatment no') else: jou.define.models.viscous.near_wall_treatment.set(wall_function) jou.solve.monitors.residual.convergence_criteria.set(1e-6) jou.surface.line_surface.set('cut-1', .1, 0, .1, .005) jou.surface.line_surface.set('cut-2', .9, 0, .9, .005) jou.define.boundary_conditions.velocity_inlet.set('inlet', Helper.reynolds.get(r_key), 300) jou.define.boundary_conditions.pressure_outlet.set('outlet', 300) jou.define.boundary_conditions.wall.set('wall', 1000) jou.define.boundary_conditions.wall.set('wall-out', 1000) jou.solve.initialize.compute_defaults.velocity_inlet.set('inlet') jou.solve.initialize.initialize_flow.set() jou.solve.iterate.set(iters) jou.report.surface_integrals.area.set(f'../../../out/out-{name}.txt', 'wall') jou.report.fluxes.heat_transfer.set(f'../../../out/out-{name}.txt', 'wall') jou.report.surface_integrals.facet_avg.set(f'../../../out/out-{name}.txt', 'temperature', 'axis') jou.report.surface_integrals.facet_avg.set(f'../../../out/out-{name}.txt', 'pressure', 'cut-1', 'cut-2') jou.file.write_case_data.set(f'../../../cas/{name}.cas') jou.save(f'../../../cls/cmd-{name}.jou') master = pj.Journal() names = [] for prefix in prefixes: for r_key in self.r_keys: for suffix in suffixes: name = self._name_constructor('00', '000', r_key, prefix = prefix, suffix = suffix) names += [name] underloop(name, r_key) master.file.read_journal.set('\n'.join([f'../../../cls/cmd-{x}.jou' for x in names])) master.save(self.folder + '/cmd.jou')
def sec_last(name): jou = pj.Journal() if self.dim == 3: jou._cmd += [f'/mesh/translate 0 0 {.1} '] else: jou.mesh.translate.set(.1, 0) jou.mesh.modify_zones.append_mesh.set(f'../../../msh/{name}.msh') jou.mesh.modify_zones.merge_zones.set('fluid', 'fluid.1') if self.dim == 2: jou.mesh.modify_zones.merge_zones.set('axis', 'axis.1') jou.mesh.modify_zones.merge_zones.set('interior', 'interior.1') jou.mesh.modify_zones.merge_zones.set('interior-fluid', 'interior-fluid.1') jou.mesh.modify_zones.merge_zones.set('wall-out', 'wall') jou.mesh.modify_zones.fuse_face_zones.set('inlet', 'outlet.1', fused_name = 'delete-me') jou.mesh.modify_zones.merge_zones.set('interior', 'delete-me') jou.mesh.modify_zones.zone_name.set('inlet.1', 'inlet') return jou
def sec_nth(name, p_key): jou = pj.Journal() if self.dim == 3: jou._cmd += [f'/mesh/translate 0 0 {Helper.pitches.get(p_key)} '] else: jou.mesh.translate.set(Helper.pitches.get(p_key), 0) jou.mesh.modify_zones.append_mesh.set(f'../../../msh/{name}.msh') jou.mesh.modify_zones.merge_zones.set('fluid', 'fluid.1') jou.mesh.modify_zones.merge_zones.set('solid', 'solid.1') if self.dim == 2: jou.mesh.modify_zones.merge_zones.set('axis', 'axis.1') jou.mesh.modify_zones.merge_zones.set('interior', 'interior.1') jou.mesh.modify_zones.merge_zones.set('interior-fluid', 'interior-fluid.1') jou.mesh.modify_zones.merge_zones.set('interior-solid', 'interior-solid.1') jou.mesh.modify_zones.merge_zones.set('sides', 'sides.1') jou.mesh.modify_zones.merge_zones.set('wall-fluid', 'wall-fluid.1') jou.mesh.modify_zones.merge_zones.set('wall-solid', 'wall-solid.1') jou.mesh.modify_zones.fuse_face_zones.set('inlet', 'outlet.1', fused_name = 'delete-me') jou.mesh.modify_zones.merge_zones.set('interior', 'delete-me') jou.mesh.modify_zones.zone_name.set('inlet.1', 'inlet') return jou
def underloop(name, h_key, p_key, r_key, suffix): jou = pj.Journal() jou.file.read_case.set('../../../cas/start.cas') jou.file.mesh_replace.set(f'../../../msh/{stab_name}-{h_key}-100-{r_key}.msh') jou += sec_first(f'{test_name}-{name}', p_key) section_nth = sec_nth(f'{test_name}-{name}', p_key) for i in range(int(8e-1/Helper.pitches[p_key])): jou += section_nth jou += sec_last(f'{stab_name}-{h_key}-100-{r_key}') jou.mesh.check.set() jou.mesh.repair_improve.repair.set() jou.surface.line_surface.set('cut-1', .1, 0, .1, .005) jou.surface.line_surface.set('cut-2', .9, 0, .9, .005) jou.define.boundary_conditions.velocity_inlet.set('inlet', Helper.reynolds.get(r_key), 300) jou.define.boundary_conditions.pressure_outlet.set('outlet', 300) jou.define.boundary_conditions.wall.set('wall-fluid', 1000) jou.define.boundary_conditions.wall.set('wall-solid', 1000, fluid = False) jou.define.boundary_conditions.wall.set('wall-out', 1000) jou.file.write_case.set(f'../../../cas/{name}.cas') jou.save(f'../../../cls/cmd-{name}.jou')
def build(self, test_name, stab_name, **kwargs): prefixes = self._kwarg_parse(kwargs.get('prefixes'), [None]) suffixes = self._kwarg_parse(kwargs.get('suffixes'), [None]) self.job = 'build' if not self.local: self._cluster() master = pj.Journal() names = [] def sec_first(name, p_key): jou = pj.Journal() if self.dim == 3: jou._cmd += [f'/mesh/translate 0 0 {Helper.pitches.get(p_key)} '] else: jou.mesh.translate.set(Helper.pitches.get(p_key), 0) jou.mesh.modify_zones.append_mesh.set(f'../../../msh/{name}.msh') jou.mesh.modify_zones.merge_zones.set('fluid', 'fluid.1') if self.dim == 2: jou.mesh.modify_zones.merge_zones.set('axis', 'axis.1') jou.mesh.modify_zones.merge_zones.set('interior', 'interior.1') jou.mesh.modify_zones.merge_zones.set('interior-fluid', 'interior-fluid.1') jou.mesh.modify_zones.zone_name.set('wall', 'wall-out') jou.mesh.modify_zones.fuse_face_zones.set('inlet', 'outlet.1', fused_name = 'delete-me') jou.mesh.modify_zones.merge_zones.set('interior', 'delete-me') jou.mesh.modify_zones.zone_name.set('inlet.1', 'inlet') return jou def sec_nth(name, p_key): jou = pj.Journal() if self.dim == 3: jou._cmd += [f'/mesh/translate 0 0 {Helper.pitches.get(p_key)} '] else: jou.mesh.translate.set(Helper.pitches.get(p_key), 0) jou.mesh.modify_zones.append_mesh.set(f'../../../msh/{name}.msh') jou.mesh.modify_zones.merge_zones.set('fluid', 'fluid.1') jou.mesh.modify_zones.merge_zones.set('solid', 'solid.1') if self.dim == 2: jou.mesh.modify_zones.merge_zones.set('axis', 'axis.1') jou.mesh.modify_zones.merge_zones.set('interior', 'interior.1') jou.mesh.modify_zones.merge_zones.set('interior-fluid', 'interior-fluid.1') jou.mesh.modify_zones.merge_zones.set('interior-solid', 'interior-solid.1') jou.mesh.modify_zones.merge_zones.set('sides', 'sides.1') jou.mesh.modify_zones.merge_zones.set('wall-fluid', 'wall-fluid.1') jou.mesh.modify_zones.merge_zones.set('wall-solid', 'wall-solid.1') jou.mesh.modify_zones.fuse_face_zones.set('inlet', 'outlet.1', fused_name = 'delete-me') jou.mesh.modify_zones.merge_zones.set('interior', 'delete-me') jou.mesh.modify_zones.zone_name.set('inlet.1', 'inlet') return jou def sec_last(name): jou = pj.Journal() if self.dim == 3: jou._cmd += [f'/mesh/translate 0 0 {.1} '] else: jou.mesh.translate.set(.1, 0) jou.mesh.modify_zones.append_mesh.set(f'../../../msh/{name}.msh') jou.mesh.modify_zones.merge_zones.set('fluid', 'fluid.1') if self.dim == 2: jou.mesh.modify_zones.merge_zones.set('axis', 'axis.1') jou.mesh.modify_zones.merge_zones.set('interior', 'interior.1') jou.mesh.modify_zones.merge_zones.set('interior-fluid', 'interior-fluid.1') jou.mesh.modify_zones.merge_zones.set('wall-out', 'wall') jou.mesh.modify_zones.fuse_face_zones.set('inlet', 'outlet.1', fused_name = 'delete-me') jou.mesh.modify_zones.merge_zones.set('interior', 'delete-me') jou.mesh.modify_zones.zone_name.set('inlet.1', 'inlet') return jou def underloop(name, h_key, p_key, r_key, suffix): jou = pj.Journal() jou.file.read_case.set('../../../cas/start.cas') jou.file.mesh_replace.set(f'../../../msh/{stab_name}-{h_key}-100-{r_key}.msh') jou += sec_first(f'{test_name}-{name}', p_key) section_nth = sec_nth(f'{test_name}-{name}', p_key) for i in range(int(8e-1/Helper.pitches[p_key])): jou += section_nth jou += sec_last(f'{stab_name}-{h_key}-100-{r_key}') jou.mesh.check.set() jou.mesh.repair_improve.repair.set() jou.surface.line_surface.set('cut-1', .1, 0, .1, .005) jou.surface.line_surface.set('cut-2', .9, 0, .9, .005) jou.define.boundary_conditions.velocity_inlet.set('inlet', Helper.reynolds.get(r_key), 300) jou.define.boundary_conditions.pressure_outlet.set('outlet', 300) jou.define.boundary_conditions.wall.set('wall-fluid', 1000) jou.define.boundary_conditions.wall.set('wall-solid', 1000, fluid = False) jou.define.boundary_conditions.wall.set('wall-out', 1000) jou.file.write_case.set(f'../../../cas/{name}.cas') jou.save(f'../../../cls/cmd-{name}.jou') master = pj.Journal() names = [] for prefix in prefixes: for r_key in self.r_keys: for h_key in self.h_keys: for p_key in self.p_keys: for suffix in suffixes: name = self._name_constructor(h_key, p_key, r_key, prefix = prefix, suffix = suffix) names += [name] underloop(name, h_key, p_key, r_key, suffix) master.file.read_journal.set('\n'.join([f'../../../cls/cmd-{x}.jou' for x in names])) master.save(self.folder + '/cmd.jou')