Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
8106f5d
Merge pull request #3 from NREL/dev
arswalid Mar 5, 2024
e229fc0
rename greek variables, rename duplicate k fn, comment unused fns
eyoung55 May 29, 2025
05e2882
remove unused imports, create linear problem, solve and write tensor …
eyoung55 May 29, 2025
ab35b41
add form for projecting P_, remove ufl.dx from k_nominal and add dire…
eyoung55 May 29, 2025
03a149a
remove unused code now moved to elasticityAnalysis, renaming greek vars
eyoung55 May 29, 2025
bd25235
pull updated gha file from logging branch
eyoung55 May 29, 2025
3c51786
remove the von mises stress function
eyoung55 May 29, 2025
08db451
save the velocity and acceleration functions directly, remove saving …
eyoung55 May 29, 2025
d713434
remember to save old, which after solve is equiv to new, since new is…
eyoung55 May 29, 2025
6f94f80
name things to reduce confusion when postprocessing, remove names fro…
eyoung55 May 29, 2025
a97b91d
Merge branch 'dev' into struct-tensor
eyoung55 May 30, 2025
1fe88b6
black formatting
eyoung55 May 30, 2025
cc48568
Merge branch 'dev' into struct-tensor
eyoung55 Jun 18, 2025
85d782a
Merge pull request #6 from NREL/dev
arswalid Jun 22, 2025
569df4d
Merge branch 'dev' into struct-tensor
eyoung55 Jun 23, 2025
9c5a5de
avoid reading the mesh if analysis set to false
arswalid Jun 23, 2025
121fc5e
black formatted
arswalid Jun 23, 2025
eb90544
initial push to prep PR
arswalid Jun 25, 2025
75669b8
black format
arswalid Jun 25, 2025
31208d1
black format main
arswalid Jun 25, 2025
97d6a6a
fixing input files
arswalid Jun 25, 2025
472610a
testing all inputs
arswalid Jun 25, 2025
6db2333
Merge pull request #7 from eyoung55/struct-tensor
arswalid Jun 25, 2025
110ebc1
missing self in structure for hmin
arswalid Jun 25, 2025
454e998
fix test_all
arswalid Jun 26, 2025
85050c4
Stop tracking input
arswalid Jun 26, 2025
498555a
black format
arswalid Jun 26, 2025
cc11fae
conftest
arswalid Jun 26, 2025
3928f0d
update location of input
arswalid Jun 26, 2025
fcd4c56
black format
arswalid Jun 26, 2025
ec4e351
reduce from 8 to 4 cores for test all
arswalid Jun 26, 2025
0a05747
removing 4 cores runs
arswalid Jun 30, 2025
f03a4ab
fixing errors and removing unnecessary print statements
brookeslawski Jun 30, 2025
c1a91cd
addition of structure anlysis in panel3d
arswalid Jun 30, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/test_pvade.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ jobs:
- name: Run pytest
shell: bash -l {0}
run: PYTHONPATH=. pytest -sv pvade/tests/
- name: test all inputs
shell: bash -l {0}
run: pytest -sv test_all_inputs.py

# Job 2 of 2 - enforce Black formatting
formatting:
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@
*.h5

docs/_build/
results/
results/input/
input/
29 changes: 29 additions & 0 deletions conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from pathlib import Path


def pytest_addoption(parser):
parser.addoption(
"--input-file",
action="store",
default=None,
help="Run test only for a specific input YAML file",
)


def pytest_generate_tests(metafunc):
if "input_file" not in metafunc.fixturenames:
return

input_file_arg = metafunc.config.getoption("input_file")

if input_file_arg:
metafunc.parametrize("input_file", [Path(input_file_arg)])
else:
# 🔧 Always resolve input/ relative to location of conftest.py (PVade/)
this_dir = Path(__file__).resolve().parent # PVade/
input_dir = this_dir / "input"

all_files = sorted(input_dir.glob("*.yaml"))
if not all_files:
raise RuntimeError(f"No input files found in {input_dir}")
metafunc.parametrize("input_file", all_files)
28 changes: 14 additions & 14 deletions input/3d_cyld.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,26 @@ domain:
y_max: 0.41
z_min: 0.0
z_max: 0.41
l_char: 2.0 #.02
pv_array:
stream_rows: 1 # not used
elevation: 1.5 # not used
stream_spacing: 7.0 # not used
panel_chord: 2.0 # not used
panel_span: 7.0 # not used
panel_thickness: 0.1 # not used
tracker_angle: 30.0 # not used
l_char: 5.0 #.02
# pv_array:
# stream_rows: 1 # not used
# elevation: 1.5 # not used
# stream_spacing: 7.0 # not used
# panel_chord: 2.0 # not used
# panel_span: 7.0 # not used
# panel_thickness: 0.1 # not used
# tracker_angle: 30.0 # not used
solver:
dt: 0.025
t_final: 0.1
solver1_ksp: cg
dt: 0.001
t_final: 0.01
solver1_ksp: gmres
solver2_ksp: cg
solver3_ksp: cg
solver1_pc: jacobi
solver2_pc: jacobi
solver3_pc: jacobi
save_text_interval: 0.1
save_xdmf_interval: 0.1
save_text_interval: 0.001
save_xdmf_interval: 0.001
fluid:
velocity_profile_type: parabolic
inflow_coeff: 16 # only necessary/used when applying a parabolic vel profile
Expand Down
1 change: 1 addition & 0 deletions input/heated_panels2d.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ domain:
l_char: 0.1
pv_array:
stream_rows: 8
span_rows: 1
elevation: 1.5
stream_spacing: 5.0
panel_chord: 2.0
Expand Down
2 changes: 1 addition & 1 deletion input/inflow_input.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ solver:
solver1_ksp: gmres
solver2_ksp: gmres
solver3_ksp: gmres
solver4_ksp: gmres
# solver4_ksp: gmres
solver1_pc: hypre
solver2_pc: hypre
solver3_pc: hypre
Expand Down
3 changes: 2 additions & 1 deletion input/panels2d.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ domain:
x_max: 50
y_min: 0
y_max: 20
l_char: 0.9
l_char: 0.5
pv_array:
stream_rows: 1
span_rows: 1
elevation: 1.5
stream_spacing: 7.0
panel_chord: 2.0
Expand Down
2 changes: 1 addition & 1 deletion input/panels3d.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,4 @@ structure:
body_force_y: 0
body_force_z: -1 #100
bc_list: [left ]
tube_connection: False
tube_connection: False
4 changes: 2 additions & 2 deletions input/single_heliostat.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ domain:
y_max: 20 # 20+39 39 is panel to panel
z_min: 0
z_max: 40
l_char: 1.25 # 1.0
l_char: 4 #1.25 # 1.0
pv_array:
stream_rows: 1
elevation: 5.5
Expand All @@ -38,7 +38,7 @@ solver:
save_text_interval: .02 #0.01
save_xdmf_interval: .02 #0.01
fluid:
time_varying_inflow_bc: false # true
# time_varying_inflow_bc: false # true
u_ref: 2.0
rho: 1.0
nu: 1.8e-05
Expand Down
73 changes: 0 additions & 73 deletions input/test_heatedpanels2d.yaml

This file was deleted.

59 changes: 47 additions & 12 deletions pvade/IO/DataStream.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
from dolfinx.io import XDMFFile

# import logging
import dolfinx
import ufl
import sys

import numpy as np

from datetime import datetime

# from dolfinx.fem import create_nonmatching_meshes_interpolation_data
# import logging


def start_print_and_log(rank, logfile_name):

Expand Down Expand Up @@ -74,7 +79,7 @@ class DataStream:

"""

def __init__(self, domain, flow, structure, params):
def __init__(self, domain, flow, structure=None, params=None):
"""Initialize the DataStream object

This initializes an object that manages the I/O for all of PVade.
Expand All @@ -98,7 +103,9 @@ def __init__(self, domain, flow, structure, params):
f"{params.general.output_dir_sol}/solution_fluid.xdmf"
)

with XDMFFile(self.comm, self.results_filename_fluid, "w") as xdmf_file:
with dolfinx.io.XDMFFile(
self.comm, self.results_filename_fluid, "w"
) as xdmf_file:
tt = 0.0
xdmf_file.write_mesh(domain.fluid.msh)
xdmf_file.write_function(flow.u_k, 0.0)
Expand All @@ -115,13 +122,31 @@ def __init__(self, domain, flow, structure, params):
f"{params.general.output_dir_sol}/solution_structure.xdmf"
)

with XDMFFile(self.comm, self.results_filename_structure, "w") as xdmf_file:
# Since this is the first call, build solvers that project forms on an as-saved basis
# Set up the linear problem used for the projection, cg solver and jacobi pc
petsc_options = {"ksp_type": "cg", "pc_type": "jacobi"}
self.prob_k_nominal = dolfinx.fem.petsc.LinearProblem(
ufl.lhs(structure.elasticity.k_nominal_proj),
ufl.rhs(structure.elasticity.k_nominal_proj),
bcs=[],
petsc_options=petsc_options,
)

# Solve for the stress tensor
sol_k_nominal = self.prob_k_nominal.solve()
structure.elasticity.internal_stress.x.array[:] = sol_k_nominal.x.array[:]
structure.elasticity.internal_stress.x.scatter_forward()

with dolfinx.io.XDMFFile(
self.comm, self.results_filename_structure, "w"
) as xdmf_file:
tt = 0.0
xdmf_file.write_mesh(domain.structure.msh)
xdmf_file.write_function(structure.elasticity.u, 0.0)
xdmf_file.write_function(structure.elasticity.stress, 0.0)
xdmf_file.write_function(structure.elasticity.v_old, 0.0)
xdmf_file.write_function(structure.elasticity.sigma_vm_h, 0.0)
xdmf_file.write_function(structure.elasticity.a_old, 0.0)
xdmf_file.write_function(structure.elasticity.stress, 0.0)
xdmf_file.write_function(structure.elasticity.internal_stress, 0.0)

if self.comm.rank == 0 and self.comm.size > 1 and params.general.test:
self.log_filename_structure = f"{params.general.output_dir_sol}/log_str.txt"
Expand Down Expand Up @@ -188,7 +213,9 @@ def save_XDMF_files(self, fsi_object, domain, tt):
"""

if fsi_object.name == "fluid":
with XDMFFile(self.comm, self.results_filename_fluid, "a") as xdmf_file:
with dolfinx.io.XDMFFile(
self.comm, self.results_filename_fluid, "a"
) as xdmf_file:
xdmf_file.write_function(fsi_object.u_k, tt)
xdmf_file.write_function(fsi_object.p_k, tt)
xdmf_file.write_function(fsi_object.panel_stress, tt)
Expand All @@ -197,11 +224,19 @@ def save_XDMF_files(self, fsi_object, domain, tt):
xdmf_file.write_function(fsi_object.theta_k, tt)

elif fsi_object.name == "structure":
with XDMFFile(self.comm, self.results_filename_structure, "a") as xdmf_file:
# Solve for the stress tensor
sol_k_nominal = self.prob_k_nominal.solve()
fsi_object.elasticity.internal_stress.x.array[:] = sol_k_nominal.x.array[:]
fsi_object.elasticity.internal_stress.x.scatter_forward()

with dolfinx.io.XDMFFile(
self.comm, self.results_filename_structure, "a"
) as xdmf_file:
xdmf_file.write_function(fsi_object.elasticity.u, tt)
xdmf_file.write_function(fsi_object.elasticity.stress, tt)
xdmf_file.write_function(fsi_object.elasticity.v_old, tt)
xdmf_file.write_function(fsi_object.elasticity.sigma_vm_h, tt)
xdmf_file.write_function(fsi_object.elasticity.a_old, tt)
xdmf_file.write_function(fsi_object.elasticity.stress, tt)
xdmf_file.write_function(fsi_object.elasticity.internal_stress, tt)

else:
raise ValueError(
Expand Down
2 changes: 1 addition & 1 deletion pvade/IO/Utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def get_input_file():
return input_file_path


def write_metrics(flow, elasticity, prof_filename="profiling.txt"):
def write_metrics(flow, prof_filename="profiling.txt"):
with open(prof_filename, "r") as output_file:
if flow.fluid_analysis == True:
# solver_line = [line for line in output_file if "(solve)" in line]
Expand Down
Loading
Loading