pvade 1.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pvade-1.1.0/LICENSE.txt +28 -0
- pvade-1.1.0/PKG-INFO +87 -0
- pvade-1.1.0/README.md +56 -0
- pvade-1.1.0/pvade/IO/DataStream.py +304 -0
- pvade-1.1.0/pvade/IO/Parameters.py +485 -0
- pvade-1.1.0/pvade/IO/Utilities.py +156 -0
- pvade-1.1.0/pvade/IO/__init__.py +9 -0
- pvade-1.1.0/pvade/IO/input_schema.yaml +719 -0
- pvade-1.1.0/pvade/IO/verbosity.py +81 -0
- pvade-1.1.0/pvade/__init__.py +9 -0
- pvade-1.1.0/pvade/__main__.py +4 -0
- pvade-1.1.0/pvade/application.py +232 -0
- pvade-1.1.0/pvade/cli.py +69 -0
- pvade-1.1.0/pvade/fluid/FlowManager.py +1972 -0
- pvade-1.1.0/pvade/fluid/__init__.py +1 -0
- pvade-1.1.0/pvade/fluid/boundary_conditions.py +688 -0
- pvade-1.1.0/pvade/fsi/FSI.py +98 -0
- pvade-1.1.0/pvade/fsi/__init__.py +9 -0
- pvade-1.1.0/pvade/geometry/MeshManager.py +1389 -0
- pvade-1.1.0/pvade/geometry/__init__.py +1 -0
- pvade-1.1.0/pvade/geometry/cylinder2d/DomainCreation.py +49 -0
- pvade-1.1.0/pvade/geometry/cylinder2d/__init__.py +1 -0
- pvade-1.1.0/pvade/geometry/cylinder3d/DomainCreation.py +111 -0
- pvade-1.1.0/pvade/geometry/cylinder3d/__init__.py +1 -0
- pvade-1.1.0/pvade/geometry/flag2d/DomainCreation.py +205 -0
- pvade-1.1.0/pvade/geometry/flag2d/__init__.py +1 -0
- pvade-1.1.0/pvade/geometry/heliostats3d/DomainCreation.py +1072 -0
- pvade-1.1.0/pvade/geometry/heliostats3d/__init__.py +1 -0
- pvade-1.1.0/pvade/geometry/panels2d/DomainCreation.py +362 -0
- pvade-1.1.0/pvade/geometry/panels2d/__init__.py +1 -0
- pvade-1.1.0/pvade/geometry/panels3d/DomainCreation.py +2438 -0
- pvade-1.1.0/pvade/geometry/panels3d/__init__.py +1 -0
- pvade-1.1.0/pvade/geometry/template/TemplateDomainCreation.py +236 -0
- pvade-1.1.0/pvade/geometry/template/__init__.py +1 -0
- pvade-1.1.0/pvade/structure/ElasticityAnalysis.py +1143 -0
- pvade-1.1.0/pvade/structure/ModalAnalysis.py +780 -0
- pvade-1.1.0/pvade/structure/StructureMain.py +447 -0
- pvade-1.1.0/pvade/structure/__init__.py +1 -0
- pvade-1.1.0/pvade/structure/boundary_conditions.py +457 -0
- pvade-1.1.0/pvade.egg-info/PKG-INFO +87 -0
- pvade-1.1.0/pvade.egg-info/SOURCES.txt +47 -0
- pvade-1.1.0/pvade.egg-info/dependency_links.txt +1 -0
- pvade-1.1.0/pvade.egg-info/entry_points.txt +2 -0
- pvade-1.1.0/pvade.egg-info/requires.txt +9 -0
- pvade-1.1.0/pvade.egg-info/top_level.txt +2 -0
- pvade-1.1.0/pvade_main.py +14 -0
- pvade-1.1.0/pyproject.toml +70 -0
- pvade-1.1.0/setup.cfg +4 -0
- pvade-1.1.0/setup.py +3 -0
pvade-1.1.0/LICENSE.txt
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
BSD 3-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 Alliance for Sustainable Energy, LLC
|
|
4
|
+
|
|
5
|
+
Redistribution and use in source and binary forms, with or without
|
|
6
|
+
modification, are permitted provided that the following conditions are met:
|
|
7
|
+
|
|
8
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
9
|
+
list of conditions and the following disclaimer.
|
|
10
|
+
|
|
11
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
12
|
+
this list of conditions and the following disclaimer in the documentation
|
|
13
|
+
and/or other materials provided with the distribution.
|
|
14
|
+
|
|
15
|
+
3. Neither the name of the copyright holder nor the names of its
|
|
16
|
+
contributors may be used to endorse or promote products derived from
|
|
17
|
+
this software without specific prior written permission.
|
|
18
|
+
|
|
19
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
20
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
21
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
22
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
23
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
24
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
25
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
26
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
27
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
28
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
pvade-1.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pvade
|
|
3
|
+
Version: 1.1.0
|
|
4
|
+
Summary: Fluid-structure interaction modeling of wind loads on solar-tracking photovoltaic arrays
|
|
5
|
+
Author: Ethan Young, Walid Arsalane, Brooke Stanislawski, Xin He, Chris Ivanov, Scott Dana, Michael Deceglie
|
|
6
|
+
License-Expression: BSD-3-Clause
|
|
7
|
+
Project-URL: Homepage, https://github.com/NatLabRockies/PVade
|
|
8
|
+
Project-URL: Documentation, https://pvade.readthedocs.io/
|
|
9
|
+
Project-URL: Source, https://github.com/NatLabRockies/PVade
|
|
10
|
+
Project-URL: Issues, https://github.com/NatLabRockies/PVade/issues
|
|
11
|
+
Project-URL: Citation, https://doi.org/10.11578/dc.20231208.1
|
|
12
|
+
Keywords: photovoltaics,fluid-structure interaction,FEniCSx,wind loads,CFD,solar tracking
|
|
13
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
14
|
+
Classifier: Intended Audience :: Science/Research
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
+
Classifier: Topic :: Scientific/Engineering
|
|
17
|
+
Classifier: Topic :: Scientific/Engineering :: Physics
|
|
18
|
+
Requires-Python: <3.11,>=3.10
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
License-File: LICENSE.txt
|
|
21
|
+
Requires-Dist: gmsh
|
|
22
|
+
Requires-Dist: h5py
|
|
23
|
+
Requires-Dist: jsonschema
|
|
24
|
+
Requires-Dist: numba
|
|
25
|
+
Requires-Dist: numpy
|
|
26
|
+
Requires-Dist: pandas
|
|
27
|
+
Requires-Dist: PyYAML
|
|
28
|
+
Requires-Dist: scipy
|
|
29
|
+
Requires-Dist: tqdm
|
|
30
|
+
Dynamic: license-file
|
|
31
|
+
|
|
32
|
+
# PVade
|
|
33
|
+
|
|
34
|
+
`PVade` is an open source fluid-structure interaction model which can be used to study wind loading and stability on solar-tracking PV arrays. `PVade` can be used as part of a larger modeling chain to provide stressor inputs to mechanical module models to study the physics of failure for degradation mechanisms such as cell cracking, weathering of cracked cells, and glass breakage. For more information, visit the [PVade Documentation](https://pvade.readthedocs.io/en/latest/index.html).
|
|
35
|
+
|
|
36
|
+
[](https://github.com/NatLabRockies/PVade/actions/workflows/test_pvade.yaml)
|
|
37
|
+
[](https://pvade.readthedocs.io/en/latest/?badge=latest)
|
|
38
|
+
|
|
39
|
+
## Getting Started
|
|
40
|
+
|
|
41
|
+
New users are encouraged to review the [installation guide](https://pvade.readthedocs.io/en/latest/installing_pvade.html) for the supported Conda environment and package installation instructions.
|
|
42
|
+
|
|
43
|
+
PyPI installation instructions for PVade 1.1.0, the first public distribution, are pending successful publication. The Conda/Mamba developer workflow below is available now.
|
|
44
|
+
|
|
45
|
+
## Quick Start
|
|
46
|
+
|
|
47
|
+
1. From the repository root, create the supported scientific-computing environment:
|
|
48
|
+
```bash
|
|
49
|
+
mamba env create -f environment.yaml
|
|
50
|
+
```
|
|
51
|
+
Activate the environment:
|
|
52
|
+
```bash
|
|
53
|
+
mamba activate pvade
|
|
54
|
+
```
|
|
55
|
+
Install the checkout in editable mode without asking pip to re-resolve Conda-managed dependencies:
|
|
56
|
+
```bash
|
|
57
|
+
python -m pip install --no-deps -e .
|
|
58
|
+
```
|
|
59
|
+
2. Verify the package and command:
|
|
60
|
+
```bash
|
|
61
|
+
python -m pip show pvade
|
|
62
|
+
python -c "import pvade; print(pvade.__file__)"
|
|
63
|
+
pvade --help
|
|
64
|
+
```
|
|
65
|
+
3. Run an example from the repository root:
|
|
66
|
+
```bash
|
|
67
|
+
pvade --input examples/panels2d.yaml
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Both `--input` and `--input_file` are accepted. To install from a source checkout into an already provisioned environment, run `python -m pip install --no-deps .`. PyPI installation instructions are pending the first public release.
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
## Citation
|
|
75
|
+
|
|
76
|
+
To cite PVade, please use the "Cite this repository" feature available on the right-hand side of this repository page or copy the BibTeX reference below:
|
|
77
|
+
|
|
78
|
+
```bibtex
|
|
79
|
+
@software{Young_PVade_PV_Aerodynamic_2023,
|
|
80
|
+
author = {Young, Ethan and Arsalane, Walid and Stanislawski, Brooke and He, Xin and Ivanov, Chris and Dana, Scott and Deceglie, Michael},
|
|
81
|
+
doi = {10.11578/dc.20231208.1},
|
|
82
|
+
month = sep,
|
|
83
|
+
title = {{PVade (PV Aerodynamic Design Engineering) [SWR-23-49]}},
|
|
84
|
+
url = {https://github.com/NatLabRockies/PVade},
|
|
85
|
+
year = {2023}
|
|
86
|
+
}
|
|
87
|
+
```
|
pvade-1.1.0/README.md
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# PVade
|
|
2
|
+
|
|
3
|
+
`PVade` is an open source fluid-structure interaction model which can be used to study wind loading and stability on solar-tracking PV arrays. `PVade` can be used as part of a larger modeling chain to provide stressor inputs to mechanical module models to study the physics of failure for degradation mechanisms such as cell cracking, weathering of cracked cells, and glass breakage. For more information, visit the [PVade Documentation](https://pvade.readthedocs.io/en/latest/index.html).
|
|
4
|
+
|
|
5
|
+
[](https://github.com/NatLabRockies/PVade/actions/workflows/test_pvade.yaml)
|
|
6
|
+
[](https://pvade.readthedocs.io/en/latest/?badge=latest)
|
|
7
|
+
|
|
8
|
+
## Getting Started
|
|
9
|
+
|
|
10
|
+
New users are encouraged to review the [installation guide](https://pvade.readthedocs.io/en/latest/installing_pvade.html) for the supported Conda environment and package installation instructions.
|
|
11
|
+
|
|
12
|
+
PyPI installation instructions for PVade 1.1.0, the first public distribution, are pending successful publication. The Conda/Mamba developer workflow below is available now.
|
|
13
|
+
|
|
14
|
+
## Quick Start
|
|
15
|
+
|
|
16
|
+
1. From the repository root, create the supported scientific-computing environment:
|
|
17
|
+
```bash
|
|
18
|
+
mamba env create -f environment.yaml
|
|
19
|
+
```
|
|
20
|
+
Activate the environment:
|
|
21
|
+
```bash
|
|
22
|
+
mamba activate pvade
|
|
23
|
+
```
|
|
24
|
+
Install the checkout in editable mode without asking pip to re-resolve Conda-managed dependencies:
|
|
25
|
+
```bash
|
|
26
|
+
python -m pip install --no-deps -e .
|
|
27
|
+
```
|
|
28
|
+
2. Verify the package and command:
|
|
29
|
+
```bash
|
|
30
|
+
python -m pip show pvade
|
|
31
|
+
python -c "import pvade; print(pvade.__file__)"
|
|
32
|
+
pvade --help
|
|
33
|
+
```
|
|
34
|
+
3. Run an example from the repository root:
|
|
35
|
+
```bash
|
|
36
|
+
pvade --input examples/panels2d.yaml
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Both `--input` and `--input_file` are accepted. To install from a source checkout into an already provisioned environment, run `python -m pip install --no-deps .`. PyPI installation instructions are pending the first public release.
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
## Citation
|
|
44
|
+
|
|
45
|
+
To cite PVade, please use the "Cite this repository" feature available on the right-hand side of this repository page or copy the BibTeX reference below:
|
|
46
|
+
|
|
47
|
+
```bibtex
|
|
48
|
+
@software{Young_PVade_PV_Aerodynamic_2023,
|
|
49
|
+
author = {Young, Ethan and Arsalane, Walid and Stanislawski, Brooke and He, Xin and Ivanov, Chris and Dana, Scott and Deceglie, Michael},
|
|
50
|
+
doi = {10.11578/dc.20231208.1},
|
|
51
|
+
month = sep,
|
|
52
|
+
title = {{PVade (PV Aerodynamic Design Engineering) [SWR-23-49]}},
|
|
53
|
+
url = {https://github.com/NatLabRockies/PVade},
|
|
54
|
+
year = {2023}
|
|
55
|
+
}
|
|
56
|
+
```
|
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
"""Input/output utilities for PVade simulations.
|
|
2
|
+
|
|
3
|
+
This module provides:
|
|
4
|
+
|
|
5
|
+
* :func:`start_print_and_log` – redirect ``stdout`` and ``stderr`` to a log
|
|
6
|
+
file while still echoing output to the terminal.
|
|
7
|
+
* :class:`DataStream` – manages XDMF solution files, writing initial and
|
|
8
|
+
per-timestep snapshots of velocity, pressure, displacement, stress, and
|
|
9
|
+
optional temperature fields.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
import dolfinx
|
|
13
|
+
import ufl
|
|
14
|
+
import sys
|
|
15
|
+
|
|
16
|
+
import numpy as np
|
|
17
|
+
|
|
18
|
+
from datetime import datetime
|
|
19
|
+
from pvade.IO.verbosity import (
|
|
20
|
+
get_verbosity_level,
|
|
21
|
+
should_emit_terminal_message,
|
|
22
|
+
parse_verbosity_print,
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
# from dolfinx.fem import create_nonmatching_meshes_interpolation_data
|
|
26
|
+
# import logging
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def start_print_and_log(rank, logfile_name):
|
|
30
|
+
"""Redirect ``stdout`` and ``stderr`` to a timestamped log file.
|
|
31
|
+
|
|
32
|
+
Replaces the process ``sys.stdout`` and ``sys.stderr`` with
|
|
33
|
+
:class:`PrintAndLog` instances that tee output to both the terminal and
|
|
34
|
+
the file *logfile_name*. The log file is initialised as an empty file
|
|
35
|
+
before redirection begins.
|
|
36
|
+
|
|
37
|
+
Args:
|
|
38
|
+
rank (int): MPI rank of the calling process.
|
|
39
|
+
logfile_name (str): Full path to the log file that will be created (or
|
|
40
|
+
overwritten if it already exists).
|
|
41
|
+
"""
|
|
42
|
+
|
|
43
|
+
class PrintAndLog:
|
|
44
|
+
"""
|
|
45
|
+
A class to capture normal print statements in a log file
|
|
46
|
+
along with displaying them to the terminal as usual.
|
|
47
|
+
"""
|
|
48
|
+
|
|
49
|
+
def __init__(self, logfile_name, rank, message_type):
|
|
50
|
+
self.logfile_name = logfile_name
|
|
51
|
+
self.rank = rank
|
|
52
|
+
self.message_type = message_type
|
|
53
|
+
self.verbosity_level = get_verbosity_level()
|
|
54
|
+
|
|
55
|
+
if message_type == "INFO":
|
|
56
|
+
self.terminal = sys.__stdout__
|
|
57
|
+
elif message_type == "ERROR":
|
|
58
|
+
self.terminal = sys.__stdout__
|
|
59
|
+
else:
|
|
60
|
+
raise ValueError(f"Type {message_type} not recognized")
|
|
61
|
+
|
|
62
|
+
def write(self, message):
|
|
63
|
+
# Write to both the command line and save to the logfile
|
|
64
|
+
cleaned_message = message.rstrip()
|
|
65
|
+
|
|
66
|
+
# Can include a test like `len(message) > 0 and self.rank == 0`
|
|
67
|
+
# to limit this to only printing from rank 0, but for parallel
|
|
68
|
+
# debugging, it is often helpful to see messages from all ranks
|
|
69
|
+
# so we omit this check for now.
|
|
70
|
+
if len(cleaned_message) > 0:
|
|
71
|
+
|
|
72
|
+
required_level, cleaned_message = parse_verbosity_print(cleaned_message)
|
|
73
|
+
|
|
74
|
+
terminal_message = cleaned_message
|
|
75
|
+
if self.verbosity_level >= 2 and self.message_type == "INFO":
|
|
76
|
+
terminal_message = f"[rank {self.rank}] {terminal_message}"
|
|
77
|
+
|
|
78
|
+
if should_emit_terminal_message(
|
|
79
|
+
self.rank,
|
|
80
|
+
self.message_type,
|
|
81
|
+
self.verbosity_level,
|
|
82
|
+
required_level=required_level,
|
|
83
|
+
):
|
|
84
|
+
self.terminal.write(f"{terminal_message}\n")
|
|
85
|
+
|
|
86
|
+
timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
|
87
|
+
|
|
88
|
+
with open(self.logfile_name, "a") as fp:
|
|
89
|
+
fp.write(
|
|
90
|
+
f"{timestamp} [rank {self.rank}] [{self.message_type}] {cleaned_message}\n"
|
|
91
|
+
)
|
|
92
|
+
|
|
93
|
+
def flush(self):
|
|
94
|
+
"""Flush the output stream (no-op; required by the file-like interface)."""
|
|
95
|
+
pass
|
|
96
|
+
|
|
97
|
+
with open(logfile_name, "w") as fp:
|
|
98
|
+
# Start with an empty file
|
|
99
|
+
pass
|
|
100
|
+
|
|
101
|
+
# Redirect stdout and stderr
|
|
102
|
+
sys.stdout = PrintAndLog(logfile_name, rank, message_type="INFO")
|
|
103
|
+
sys.stderr = PrintAndLog(logfile_name, rank, message_type="ERROR")
|
|
104
|
+
|
|
105
|
+
if rank == 0:
|
|
106
|
+
print("Starting PVade Run")
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
class DataStream:
|
|
110
|
+
"""Input/Output and file writing class
|
|
111
|
+
|
|
112
|
+
This class manages the generation and updating of the saved xdmf files
|
|
113
|
+
from each run along with command line outputs and log files.
|
|
114
|
+
|
|
115
|
+
Attributes:
|
|
116
|
+
comm (MPI Communicator): An MPI communicator used by all PVade objects
|
|
117
|
+
ndim (int): The number of dimensions in the problem
|
|
118
|
+
num_procs (int): The total number of processors being used to solve the problem
|
|
119
|
+
rank (int): A unique ID for each process in the range `[0, 1, ..., num_procs-1]`
|
|
120
|
+
results_filename_fluid (str): The full path to the directory in which all saved files will be written.
|
|
121
|
+
|
|
122
|
+
"""
|
|
123
|
+
|
|
124
|
+
def __init__(self, domain, flow, structure=None, params=None):
|
|
125
|
+
"""Initialize the DataStream object
|
|
126
|
+
|
|
127
|
+
This initializes an object that manages the I/O for all of PVade.
|
|
128
|
+
|
|
129
|
+
Args:
|
|
130
|
+
domain (:obj:`pvade.geometry.MeshManager.Domain`): A Domain object
|
|
131
|
+
flow (:obj:`pvade.fluid.FlowManager.Flow`): A Flow object
|
|
132
|
+
params (:obj:`pvade.Parameters.SimParams`): A SimParams object
|
|
133
|
+
|
|
134
|
+
"""
|
|
135
|
+
|
|
136
|
+
self.comm = params.comm
|
|
137
|
+
self.rank = params.rank
|
|
138
|
+
self.num_procs = params.num_procs
|
|
139
|
+
self.ndim = domain.fluid.msh.topology.dim
|
|
140
|
+
self.thermal_analysis = params.general.thermal_analysis
|
|
141
|
+
|
|
142
|
+
# If doing a fluid simulation, start a fluid solution file
|
|
143
|
+
if params.general.fluid_analysis:
|
|
144
|
+
self.results_filename_fluid = (
|
|
145
|
+
f"{params.general.output_dir_sol}/solution_fluid.xdmf"
|
|
146
|
+
)
|
|
147
|
+
|
|
148
|
+
with dolfinx.io.XDMFFile(
|
|
149
|
+
self.comm, self.results_filename_fluid, "w"
|
|
150
|
+
) as xdmf_file:
|
|
151
|
+
tt = 0.0
|
|
152
|
+
xdmf_file.write_mesh(domain.fluid.msh)
|
|
153
|
+
xdmf_file.write_function(flow.u_k, 0.0)
|
|
154
|
+
xdmf_file.write_function(flow.p_k, 0.0)
|
|
155
|
+
xdmf_file.write_function(flow.panel_stress, 0.0)
|
|
156
|
+
xdmf_file.write_function(domain.total_mesh_displacement, 0.0)
|
|
157
|
+
|
|
158
|
+
if params.general.thermal_analysis:
|
|
159
|
+
xdmf_file.write_function(flow.theta_k, 0.0)
|
|
160
|
+
|
|
161
|
+
# If doing a structure simulation, start a structure solution file
|
|
162
|
+
if params.general.structural_analysis:
|
|
163
|
+
self.results_filename_structure = (
|
|
164
|
+
f"{params.general.output_dir_sol}/solution_structure.xdmf"
|
|
165
|
+
)
|
|
166
|
+
|
|
167
|
+
# Since this is the first call, build solvers that project forms on an as-saved basis
|
|
168
|
+
# Set up the linear problem used for the projection, cg solver and jacobi pc
|
|
169
|
+
petsc_options = {"ksp_type": "cg", "pc_type": "jacobi"}
|
|
170
|
+
self.prob_k_nominal = dolfinx.fem.petsc.LinearProblem(
|
|
171
|
+
ufl.lhs(structure.elasticity.k_nominal_proj),
|
|
172
|
+
ufl.rhs(structure.elasticity.k_nominal_proj),
|
|
173
|
+
bcs=[],
|
|
174
|
+
petsc_options=petsc_options,
|
|
175
|
+
)
|
|
176
|
+
|
|
177
|
+
# Solve for the stress tensor
|
|
178
|
+
sol_k_nominal = self.prob_k_nominal.solve()
|
|
179
|
+
structure.elasticity.internal_stress.x.array[:] = sol_k_nominal.x.array[:]
|
|
180
|
+
structure.elasticity.internal_stress.x.scatter_forward()
|
|
181
|
+
|
|
182
|
+
with dolfinx.io.XDMFFile(
|
|
183
|
+
self.comm, self.results_filename_structure, "w"
|
|
184
|
+
) as xdmf_file:
|
|
185
|
+
tt = 0.0
|
|
186
|
+
xdmf_file.write_mesh(domain.structure.msh)
|
|
187
|
+
xdmf_file.write_function(structure.elasticity.u, 0.0)
|
|
188
|
+
xdmf_file.write_function(structure.elasticity.v_old, 0.0)
|
|
189
|
+
xdmf_file.write_function(structure.elasticity.a_old, 0.0)
|
|
190
|
+
xdmf_file.write_function(structure.elasticity.stress, 0.0)
|
|
191
|
+
xdmf_file.write_function(structure.elasticity.internal_stress, 0.0)
|
|
192
|
+
|
|
193
|
+
if self.comm.rank == 0 and self.comm.size > 1 and params.general.test:
|
|
194
|
+
self.log_filename_structure = f"{params.general.output_dir_sol}/log_str.txt"
|
|
195
|
+
|
|
196
|
+
with open(self.log_filename_structure, "w") as fp:
|
|
197
|
+
fp.write(f"start , size of vec is {vec_check.size}\n")
|
|
198
|
+
fp.close()
|
|
199
|
+
|
|
200
|
+
for n in range(solution_vec.size):
|
|
201
|
+
with open(self.log_filename_structure, "a") as fp:
|
|
202
|
+
fp.write(
|
|
203
|
+
f"row {n}, {vec_check[n]} compared to {solution_vec[n]}, diff is {abs(vec_check[n] - solution_vec[n])}\n"
|
|
204
|
+
)
|
|
205
|
+
if abs(vec_check[n] - solution_vec[n]) > 1e-6:
|
|
206
|
+
fp.write("flag \n")
|
|
207
|
+
fp.close()
|
|
208
|
+
print(
|
|
209
|
+
f"solution vec incorrect in {n}th entry \n {vec_check[n]} compared to {solution_vec[n]} np = {self.comm.size} !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
|
|
210
|
+
)
|
|
211
|
+
exit()
|
|
212
|
+
print(f"all values match with np = {self.comm.size}")
|
|
213
|
+
|
|
214
|
+
# def store_vec_rank1(functionspace, vector):
|
|
215
|
+
# imap = vector.function_space.dofmap.index_map
|
|
216
|
+
# local_range = (
|
|
217
|
+
# np.asarray(imap.local_range, dtype=np.int32)
|
|
218
|
+
# * vector.function_space.dofmap.index_map_bs
|
|
219
|
+
# )
|
|
220
|
+
# size_global = imap.size_global * vector.function_space.dofmap.index_map_bs
|
|
221
|
+
|
|
222
|
+
# # Communicate ranges and local data
|
|
223
|
+
# ranges = MPI.COMM_WORLD.gather(local_range, root=0)
|
|
224
|
+
# data = MPI.COMM_WORLD.gather(vector.vector.array, root=0)
|
|
225
|
+
# # print(data)
|
|
226
|
+
# # Communicate local dof coordinates
|
|
227
|
+
# x = functionspace.tabulate_dof_coordinates()[: imap.size_local]
|
|
228
|
+
# x_glob = MPI.COMM_WORLD.gather(x, root=0)
|
|
229
|
+
|
|
230
|
+
# # Declare gathered parallel arrays
|
|
231
|
+
# global_array = np.zeros(size_global)
|
|
232
|
+
# global_x = np.zeros((size_global, 3))
|
|
233
|
+
# u_from_global = np.zeros(global_array.shape)
|
|
234
|
+
|
|
235
|
+
# x0 = functionspace.tabulate_dof_coordinates()
|
|
236
|
+
|
|
237
|
+
# if self.comm.rank == 0:
|
|
238
|
+
# # Create array with all values (received)
|
|
239
|
+
# for r, d in zip(ranges, data):
|
|
240
|
+
# global_array[r[0] : r[1]] = d
|
|
241
|
+
|
|
242
|
+
# return global_array
|
|
243
|
+
|
|
244
|
+
# exit()
|
|
245
|
+
|
|
246
|
+
def save_XDMF_files(self, fsi_object, domain, tt):
|
|
247
|
+
"""Write additional timestep to XDMF file
|
|
248
|
+
|
|
249
|
+
This function appends the state of the flow at time `tt` to an existing XDMF file.
|
|
250
|
+
|
|
251
|
+
Args:
|
|
252
|
+
flow (:obj:`pvade.fluid.FlowManager.Flow`): A Flow object
|
|
253
|
+
tt (float): The time at which the current solution exists
|
|
254
|
+
|
|
255
|
+
"""
|
|
256
|
+
|
|
257
|
+
if fsi_object.name == "fluid":
|
|
258
|
+
with dolfinx.io.XDMFFile(
|
|
259
|
+
self.comm, self.results_filename_fluid, "a"
|
|
260
|
+
) as xdmf_file:
|
|
261
|
+
xdmf_file.write_function(fsi_object.u_k, tt)
|
|
262
|
+
xdmf_file.write_function(fsi_object.p_k, tt)
|
|
263
|
+
xdmf_file.write_function(fsi_object.panel_stress, tt)
|
|
264
|
+
xdmf_file.write_function(domain.total_mesh_displacement, tt)
|
|
265
|
+
if self.thermal_analysis:
|
|
266
|
+
xdmf_file.write_function(fsi_object.theta_k, tt)
|
|
267
|
+
|
|
268
|
+
elif fsi_object.name == "structure":
|
|
269
|
+
# Solve for the stress tensor
|
|
270
|
+
sol_k_nominal = self.prob_k_nominal.solve()
|
|
271
|
+
fsi_object.elasticity.internal_stress.x.array[:] = sol_k_nominal.x.array[:]
|
|
272
|
+
fsi_object.elasticity.internal_stress.x.scatter_forward()
|
|
273
|
+
|
|
274
|
+
with dolfinx.io.XDMFFile(
|
|
275
|
+
self.comm, self.results_filename_structure, "a"
|
|
276
|
+
) as xdmf_file:
|
|
277
|
+
xdmf_file.write_function(fsi_object.elasticity.u, tt)
|
|
278
|
+
xdmf_file.write_function(fsi_object.elasticity.v_old, tt)
|
|
279
|
+
xdmf_file.write_function(fsi_object.elasticity.a_old, tt)
|
|
280
|
+
xdmf_file.write_function(fsi_object.elasticity.stress, tt)
|
|
281
|
+
xdmf_file.write_function(fsi_object.elasticity.internal_stress, tt)
|
|
282
|
+
|
|
283
|
+
else:
|
|
284
|
+
raise ValueError(
|
|
285
|
+
f"Got found fsi object name = {fsi_object.name}, not recognized."
|
|
286
|
+
)
|
|
287
|
+
|
|
288
|
+
# def fluid_struct(self, domain, flow, elasticity, params):
|
|
289
|
+
# # print("tst")
|
|
290
|
+
|
|
291
|
+
# elasticity.stress_old.x.array[:] = elasticity.stress.x.array
|
|
292
|
+
# elasticity.stress_old.x.scatter_forward()
|
|
293
|
+
|
|
294
|
+
# elasticity.stress.interpolate(flow.panel_stress_undeformed)
|
|
295
|
+
# elasticity.stress.x.scatter_forward()
|
|
296
|
+
|
|
297
|
+
# beta = params.structure.beta_relaxation
|
|
298
|
+
|
|
299
|
+
# elasticity.stress.x.array[:] = (
|
|
300
|
+
# beta * elasticity.stress.x.array
|
|
301
|
+
# + (1.0 - beta) * elasticity.stress_predicted.x.array
|
|
302
|
+
# )
|
|
303
|
+
|
|
304
|
+
# elasticity.stress.x.scatter_forward()
|