{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Generate pressure coefficients" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Initialize Path Manager" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "from cfdmod.use_cases.pressure.path_manager import CpPathManager\n", "import pathlib\n", "\n", "path_manager = CpPathManager(output_path=pathlib.Path(\"./output/pressure\"))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Read post-processing Cp config file" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "CpCaseConfig(pressure_coefficient={'default': CpConfig(statistics=[BasicStatisticModel(stats='mean', display_name=''), BasicStatisticModel(stats='rms', display_name=''), BasicStatisticModel(stats='skewness', display_name=''), BasicStatisticModel(stats='kurtosis', display_name=''), ParameterizedStatisticModel(stats='mean_eq', display_name='', params=MeanEquivalentParamsModel(scale_factor=0.61)), ParameterizedStatisticModel(stats='min', display_name='', params=ExtremeAbsoluteParamsModel(method_type='Absolute')), ParameterizedStatisticModel(stats='max', display_name='', params=ExtremeGumbelParamsModel(method_type='Gumbel', peak_duration=3.0, event_duration=600.0, n_subdivisions=10, non_exceedance_probability=0.78, full_scale_U_H=40.0, full_scale_characteristic_length=22.4))], number_of_chunks=10, timestep_range=(10000.0, 20000.0), reference_pressure='average', simul_U_H=0.05, simul_characteristic_length=0.8445)})" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from cfdmod.use_cases.pressure.cp_config import CpCaseConfig\n", "\n", "cfg_path = pathlib.Path(\"./fixtures/tests/pressure/cp_params.yaml\")\n", "post_proc_cfg = CpCaseConfig.from_file(cfg_path)\n", "\n", "post_proc_cfg" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Read LNAS Mesh" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "((1549, 3), (2915, 3))" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from lnas import LnasFormat\n", "\n", "mesh_path = pathlib.Path(\"./fixtures/tests/pressure/galpao/galpao.lnas\")\n", "mesh = LnasFormat.from_file(mesh_path)\n", "\n", "mesh.geometry.vertices.shape, mesh.geometry.triangles.shape" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Read hist series" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "static_data_path = pathlib.Path(\n", " \"./fixtures/tests/pressure/data/new.points.static_pressure.data.resampled.h5\"\n", ")\n", "body_data_path = pathlib.Path(\"./fixtures/tests/pressure/data/new.bodies.galpao.data.resampled.h5\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Process pressure coefficient use case" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\u001b[37m[2024-05-23 12:03:27,727] [INFO] - cfdmod - Processing pressure coefficients for config default ... (739055453.py:7)\u001b[39m\n", "\u001b[37m[2024-05-23 12:03:27,728] [INFO] - cfdmod - Transforming into pressure coefficient (cp_data.py:184)\u001b[39m\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "/home/ubuntu/Documentos/Repositories/cfdmod/cfdmod/use_cases/pressure/cp_data.py:178: RuntimeWarning: Path for time series already exists output/pressure/cp/default/cp.time_series.h5. Deleted old file\n", " warnings.warn(\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "\u001b[37m[2024-05-23 12:03:31,568] [INFO] - cfdmod - Dividing into point groups (cp_data.py:201)\u001b[39m\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "/home/ubuntu/Documentos/Repositories/cfdmod/cfdmod/use_cases/pressure/cp_data.py:195: RuntimeWarning: Path for grouped time series already exists output/pressure/cp/default/time_series.grouped.h5. Deleted old file\n", " warnings.warn(\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "\u001b[37m[2024-05-23 12:03:32,454] [INFO] - cfdmod - Calculating statistics (cp_data.py:208)\u001b[39m\n", "\u001b[37m[2024-05-23 12:03:33,522] [INFO] - cfdmod - Copying input artifacts (739055453.py:17)\u001b[39m\n", "\u001b[37m[2024-05-23 12:03:33,526] [INFO] - cfdmod - Processed pressure coefficients for config default! (739055453.py:27)\u001b[39m\n" ] } ], "source": [ "import shutil\n", "from cfdmod.logger import logger\n", "from cfdmod.use_cases.pressure.cp_data import process_cp\n", "from cfdmod.use_cases.pressure.path_manager import copy_input_artifacts\n", "\n", "for cfg_lbl, cfg in post_proc_cfg.pressure_coefficient.items():\n", " logger.info(f\"Processing pressure coefficients for config {cfg_lbl} ...\")\n", " process_cp(\n", " pressure_data_path=static_data_path,\n", " body_data_path=body_data_path,\n", " cfg_label=cfg_lbl,\n", " cfg=cfg,\n", " mesh=mesh.geometry,\n", " path_manager=path_manager,\n", " )\n", "\n", " logger.info(\"Copying input artifacts\")\n", " shutil.copy(cfg_path, path_manager.get_config_path(cfg_lbl))\n", " copy_input_artifacts(\n", " cfg_path=cfg_path,\n", " mesh_path=mesh_path,\n", " static_data_path=static_data_path,\n", " body_data_path=body_data_path,\n", " path_manager=path_manager,\n", " )\n", "\n", " logger.info(f\"Processed pressure coefficients for config {cfg_lbl}!\")" ] } ], "metadata": { "kernelspec": { "display_name": "cfdmod-6zl7i90Q-py3.11", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.10.12" }, "orig_nbformat": 4 }, "nbformat": 4, "nbformat_minor": 2 }