Skip to content

Commit

Permalink
Merge pull request #35 from Argonne-National-Laboratory/time_dependent
Browse files Browse the repository at this point in the history
Time dependent
  • Loading branch information
pschaugule authored Jun 26, 2023
2 parents c31c5e5 + 11aed2f commit ed7fcb6
Show file tree
Hide file tree
Showing 27 changed files with 3,261 additions and 811 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: sudo apt-get install cmake libblas-dev liblapack-dev python3-setuptools python3-pip python3-dev python3-nose pylint3
- run: sudo apt-get install cmake libblas-dev liblapack-dev python3-setuptools python3-pip python3-dev python3-nose
- run: pip3 install --user wheel
- run: pip3 install --user -r requirements.txt
- run: nosetests3
Expand Down
83 changes: 1 addition & 82 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -60,93 +60,19 @@ confidence=
# --enable=similarities". If you want to run only the classes checker, but have
# no Warning level messages displayed, use "--disable=all --enable=classes
# --disable=W".
disable=print-statement,
parameter-unpacking,
unpacking-in-except,
old-raise-syntax,
backtick,
long-suffix,
old-ne-operator,
old-octal-literal,
import-star-module-level,
non-ascii-bytes-literal,
raw-checker-failed,
disable=raw-checker-failed,
bad-inline-option,
locally-disabled,
file-ignored,
suppressed-message,
useless-suppression,
deprecated-pragma,
use-symbolic-message-instead,
apply-builtin,
basestring-builtin,
buffer-builtin,
cmp-builtin,
coerce-builtin,
execfile-builtin,
file-builtin,
long-builtin,
raw_input-builtin,
reduce-builtin,
standarderror-builtin,
unicode-builtin,
xrange-builtin,
coerce-method,
delslice-method,
getslice-method,
setslice-method,
no-absolute-import,
old-division,
dict-iter-method,
dict-view-method,
next-method-called,
metaclass-assignment,
indexing-exception,
raising-string,
reload-builtin,
oct-method,
hex-method,
nonzero-method,
cmp-method,
input-builtin,
round-builtin,
intern-builtin,
unichr-builtin,
map-builtin-not-iterating,
zip-builtin-not-iterating,
range-builtin-not-iterating,
filter-builtin-not-iterating,
using-cmp-argument,
eq-without-hash,
div-method,
idiv-method,
rdiv-method,
exception-message-attribute,
invalid-str-codec,
sys-max-int,
bad-python3-import,
deprecated-string-function,
deprecated-str-translate-call,
deprecated-itertools-function,
deprecated-types-field,
next-method-defined,
dict-items-not-iterating,
dict-keys-not-iterating,
dict-values-not-iterating,
deprecated-operator-function,
deprecated-urllib-function,
xreadlines-attribute,
deprecated-sys-function,
exception-escape,
comprehension-escape,
trailing-whitespace,
bad-whitespace,
bad-continuation,
attribute-defined-outside-init,
no-else-return,
invalid-name,
arguments-differ,
no-self-use,
too-many-instance-attributes,
unused-argument,
assignment-from-no-return,
Expand Down Expand Up @@ -224,13 +150,6 @@ max-line-length=100
# Maximum number of lines in a module.
max-module-lines=1200

# List of optional constructs for which whitespace checking is disabled. `dict-
# separator` is used to allow tabulation in dicts, etc.: {1 : 1,\n222: 2}.
# `trailing-comma` allows a space between comma and closing bracket: (a, ).
# `empty-line` allows space-only lines.
no-space-check=trailing-comma,
dict-separator

# Allow the body of a class to be on the same line as the declaration if body
# contains single statement.
single-line-class-stmt=no
Expand Down
136 changes: 136 additions & 0 deletions examples/ceramic-receiver/calculate_reliability.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
#!/usr/bin/env python3

import numpy as np

import sys

sys.path.append("../..")

from srlife import (
receiver,
solverparams,
spring,
structural,
thermal,
system,
library,
managers,
damage,
)


def sample_parameters():
params = solverparams.ParameterSet()

params["nthreads"] = 2
params["progress_bars"] = True
# If true store results on disk (slower, but less memory)
params["page_results"] = True # False

params["thermal"]["miter"] = 200
params["thermal"]["verbose"] = False

params["thermal"]["solid"]["rtol"] = 1.0e-6
params["thermal"]["solid"]["atol"] = 1.0e-4
params["thermal"]["solid"]["miter"] = 20

params["thermal"]["fluid"]["rtol"] = 1.0e-6
params["thermal"]["fluid"]["atol"] = 1.0e-2
params["thermal"]["fluid"]["miter"] = 50

params["structural"]["rtol"] = 1.0e-6
params["structural"]["atol"] = 1.0e-8
params["structural"]["miter"] = 50
params["structural"]["verbose"] = False

params["system"]["rtol"] = 1.0e-6
params["system"]["atol"] = 1.0e-8
params["system"]["miter"] = 10
params["system"]["verbose"] = False

params["damage"]["shear_sensitive"] = True

# How to extrapolate damage forward in time based on the cycles provided
# Options:
# "lump" = D_future = sum(D_simulated) / N * days
# "last" = D_future = sum(D_simulated[:-1]) + D_simulated[-1] * days
# "poly" = polynomial extrapolation with order given by the "order" param
params["damage"]["extrapolate"] = "last"
# params["damage"]["order"] = 2

return params


if __name__ == "__main__":
model = receiver.Receiver.load("SiC_1pt00mm_spath_Sresults.hdf")

# Load some customized solution parameters
# These are all optional, all the solvers have default values
# for parameters not provided by the user
params = sample_parameters()

# Define the thermal solver to use in solving the heat transfer problem
thermal_solver = thermal.ThermohydraulicsThermalSolver(params["thermal"])
# Define the structural solver to use in solving the individual tube problems
structural_solver = structural.PythonTubeSolver(params["structural"])
# Define the system solver to use in solving the coupled structural system
system_solver = system.SpringSystemSolver(params["system"])
# Damage model to use in calculating life
damage_models = [
damage.PIAModel(params["damage"]),
damage.WNTSAModel(params["damage"]),
damage.MTSModelGriffithFlaw(params["damage"]),
damage.MTSModelPennyShapedFlaw(params["damage"]),
damage.CSEModelGriffithFlaw(params["damage"]),
damage.CSEModelPennyShapedFlaw(params["damage"]),
damage.SMMModelGriffithFlaw(params["damage"]),
damage.SMMModelPennyShapedFlaw(params["damage"]),
]

# Load the materials
fluid = library.load_thermal_fluid("32MgCl2-68KCl", "base")
thermal, deformation, damage = library.load_material(
"SiC", "base", "cares", "cares"
)

reliability_filename = "SiC_1pt00mm_Reliability.txt"
file = open(reliability_filename, "w")

for damage_model in damage_models:
# The solution manager
solver = managers.SolutionManager(
model,
thermal_solver,
thermal,
fluid,
structural_solver,
deformation,
damage,
system_solver,
damage_model,
pset=params,
)

# Report the best-estimate life of the receiver
reliability = solver.calculate_reliability(time=100000.0)
model.save("SiC_1pt00mm_spath_Rresults.hdf")

for pi, panel in model.panels.items():
for ti, tube in panel.tubes.items():
tube.write_vtk("SiC_1mm_tube-%s-%s" % (pi, ti))

print(damage_model)
print("Individual tube reliabilities:")
print(reliability["tube_reliability"])
print("Individual panel reliabilities:")
print(reliability["panel_reliability"])
print("Overall reliability:")
print(reliability["overall_reliability"])
print("Minimum tube reliabilities:")
print(min(reliability["tube_reliability"]))

file.write("model = %s \n" % (damage_model))
file.write(
"minimum tube reliability = %f \n" % (min(reliability["tube_reliability"]))
)
file.close()
5 changes: 3 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
numpy
scipy
scipy==1.9.2
h5py
vtk
nose
matplotlib
pylint
pylint==2.15.5
neml
scikit-fem
meshio
Expand All @@ -15,3 +15,4 @@ dill
parameterized
black
jax[cpu]
absl-py
Loading

0 comments on commit ed7fcb6

Please sign in to comment.