-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathwf_gmd_03_dpf.py
More file actions
130 lines (103 loc) · 4 KB
/
wf_gmd_03_dpf.py
File metadata and controls
130 lines (103 loc) · 4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# Copyright (C) 2024 - 2026 ANSYS, Inc. and/or its affiliates.
# SPDX-License-Identifier: MIT
#
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
"""
.. _ref_geometry_mech_dpf_03-dpf:
Post-processing
###############
This examples shows how dataprocessing framework can be used to extract results
and analyze them.
""" # noqa: D400, D415
import os
from pathlib import Path
from ansys.dpf import core as dpf
# sphinx_gallery_start_ignore
# Check if the __file__ variable is defined. If not, set it.
# This is a workaround to run the script in Sphinx-Gallery.
if "__file__" not in locals():
__file__ = Path(os.getcwd(), "wf_gmd_03_dpf.py")
# sphinx_gallery_end_ignore
###############################################################################
# Parameters for the script
# -------------------------
# The following parameters are used to control the script execution. You can
# modify these parameters to suit your needs.
#
GRAPHICS_BOOL = False # Set to True to display the graphics
OUTPUT_DIR = Path(Path(__file__).parent, "outputs") # Output directory
# sphinx_gallery_start_ignore
if "DOC_BUILD" in os.environ:
GRAPHICS_BOOL = True
# sphinx_gallery_end_ignore
###############################################################################
# Finding necessary files for dpf
# -------------------------------
#
def find_files(directory, extension):
rst_files = []
for root, _, files in os.walk(directory):
for file in files:
if file.endswith(extension):
rst_files.append(os.path.join(root, file))
return rst_files
extension_to_find = ".rth"
# Mechanical poject directory
project_directory = os.path.join(OUTPUT_DIR, "pcb_Mech_Files")
steady_state_rth_file = find_files(
os.path.join(project_directory, "SteadyStateThermal"), extension_to_find
)
transient_rth_file = find_files(
os.path.join(project_directory, "TransientThermal"), extension_to_find
)
if steady_state_rth_file and transient_rth_file:
print(f"Found {extension_to_find} files.")
else:
print("No .rst files found.")
print(steady_state_rth_file)
print(transient_rth_file)
###############################################################################
# DPF workflow
# ------------
#
# Result precision
decimal_precision = 6
###############################################################################
# Steady state thermal results
# ----------------------------
# Create model
steady_state_model = dpf.Model(steady_state_rth_file[0])
print(steady_state_model)
# Get temperature distribution
temp = steady_state_model.results.temperature.on_last_time_freq.eval()[0]
# Plot the temperature for ic-6
if GRAPHICS_BOOL:
temp.plot()
###############################################################################
# Transient thermal results
# -------------------------
# Create model
model = dpf.Model(transient_rth_file[0])
print(steady_state_model)
# Get temperature distribution
temp = model.results.temperature.on_last_time_freq.eval()[0]
# Plot the the temperature for ic-1
if GRAPHICS_BOOL:
temp.plot()