Skip to content

Commit

Permalink
32 implement hydration model in fenicsx (#132)
Browse files Browse the repository at this point in the history
* Add ruff in pyproject.toml and remove unused imports

* Add old file

* WIP

* Add quadrature helpers

* WIP: Rewrote several functions

* Add project function and array creation for quadrature spaces

* For Annika

* WIP: Add minimal cube experiment

* rename function

* Move some stuff

* WIP: Refactoring

I changed my mind about some of the code

* Add scipy to dependencies

* WIP: Translation done

* Change input to ufl cell

* Fix QuadratureRule

* Debugging

* Still debugging

* Default_dictionary test runs

* Remove duplicate of project

* Update api docs

* Add test for QuadratureRule

* Add (empty) test file

* Make compatible to new util interface

* Thermal experiment interface

* Refactoring with fields and q_fields

* type hints

* Fix circular import

* Start with tests

* Small changes

* Try moving the SensorDict

* Pure mechanical test

* Make body forces optional

* Temperature BC

* Add 2d case

* WIP: testing hydration model

* WIP: Fix the hydration model

* Fix tests after merge

* Finish tests

* Add scipy

* Fix cleanup error....

* temperature comparison

* Update src/fenicsxconcrete/finite_element_problem/concrete_thermo_mechanical.py

Co-authored-by: Erik Tamsen <86715087+eriktamsen@users.noreply.github.com>

* Update src/fenicsxconcrete/finite_element_problem/concrete_thermo_mechanical.py

Co-authored-by: Erik Tamsen <86715087+eriktamsen@users.noreply.github.com>

* Update src/fenicsxconcrete/finite_element_problem/concrete_thermo_mechanical.py

Co-authored-by: Erik Tamsen <86715087+eriktamsen@users.noreply.github.com>

* Update src/fenicsxconcrete/finite_element_problem/concrete_thermo_mechanical.py

Co-authored-by: Erik Tamsen <86715087+eriktamsen@users.noreply.github.com>

* Update src/fenicsxconcrete/finite_element_problem/concrete_thermo_mechanical.py

Co-authored-by: Erik Tamsen <86715087+eriktamsen@users.noreply.github.com>

* Update src/fenicsxconcrete/finite_element_problem/concrete_thermo_mechanical.py

Co-authored-by: Erik Tamsen <86715087+eriktamsen@users.noreply.github.com>

* Update tests/sensor_definition/test_sensors.py

Co-authored-by: Erik Tamsen <86715087+eriktamsen@users.noreply.github.com>

* Update src/fenicsxconcrete/finite_element_problem/concrete_thermo_mechanical.py

Co-authored-by: Erik Tamsen <86715087+eriktamsen@users.noreply.github.com>

* Update src/fenicsxconcrete/finite_element_problem/concrete_thermo_mechanical.py

Co-authored-by: Erik Tamsen <86715087+eriktamsen@users.noreply.github.com>

* Update src/fenicsxconcrete/finite_element_problem/concrete_thermo_mechanical.py

Co-authored-by: Erik Tamsen <86715087+eriktamsen@users.noreply.github.com>

* Update src/fenicsxconcrete/finite_element_problem/concrete_thermo_mechanical.py

Co-authored-by: Erik Tamsen <86715087+eriktamsen@users.noreply.github.com>

* Update src/fenicsxconcrete/finite_element_problem/concrete_thermo_mechanical.py

Co-authored-by: Erik Tamsen <86715087+eriktamsen@users.noreply.github.com>

* Update src/fenicsxconcrete/finite_element_problem/concrete_thermo_mechanical.py

Co-authored-by: Erik Tamsen <86715087+eriktamsen@users.noreply.github.com>

* Update src/fenicsxconcrete/finite_element_problem/concrete_thermo_mechanical.py

Co-authored-by: Erik Tamsen <86715087+eriktamsen@users.noreply.github.com>

* Update src/fenicsxconcrete/finite_element_problem/concrete_thermo_mechanical.py

Co-authored-by: Erik Tamsen <86715087+eriktamsen@users.noreply.github.com>

* Update src/fenicsxconcrete/finite_element_problem/concrete_thermo_mechanical.py

Co-authored-by: Erik Tamsen <86715087+eriktamsen@users.noreply.github.com>

* Update src/fenicsxconcrete/finite_element_problem/concrete_thermo_mechanical.py

Co-authored-by: Erik Tamsen <86715087+eriktamsen@users.noreply.github.com>

* Update src/fenicsxconcrete/finite_element_problem/concrete_thermo_mechanical.py

Co-authored-by: Erik Tamsen <86715087+eriktamsen@users.noreply.github.com>

* Update src/fenicsxconcrete/finite_element_problem/concrete_thermo_mechanical.py

Co-authored-by: Erik Tamsen <86715087+eriktamsen@users.noreply.github.com>

* Update src/fenicsxconcrete/finite_element_problem/concrete_thermo_mechanical.py

Co-authored-by: Erik Tamsen <86715087+eriktamsen@users.noreply.github.com>

* Remove Mixin

* Remove temp_adjust_law

* Small changes

* Formatting

---------

Co-authored-by: Erik Tamsen <86715087+eriktamsen@users.noreply.github.com>
  • Loading branch information
srosenbu and eriktamsen authored Aug 29, 2023
1 parent ae72785 commit 98ccd2c
Show file tree
Hide file tree
Showing 23 changed files with 1,643 additions and 20 deletions.
8 changes: 8 additions & 0 deletions docs/api/fenicsxconcrete.finite_element_problem.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ fenicsxconcrete.finite\_element\_problem.base\_material module
:undoc-members:
:show-inheritance:

fenicsxconcrete.finite\_element\_problem.concrete\_am module
------------------------------------------------------------

.. automodule:: fenicsxconcrete.finite_element_problem.concrete_am
:members:
:undoc-members:
:show-inheritance:

fenicsxconcrete.finite\_element\_problem.concrete\_thermo\_mechanical module
----------------------------------------------------------------------------

Expand Down
8 changes: 8 additions & 0 deletions docs/api/fenicsxconcrete.sensor_definition.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ fenicsxconcrete.sensor\_definition.reaction\_force\_sensor module
:undoc-members:
:show-inheritance:

fenicsxconcrete.sensor\_definition.sensor\_schema module
--------------------------------------------------------

.. automodule:: fenicsxconcrete.sensor_definition.sensor_schema
:members:
:undoc-members:
:show-inheritance:

fenicsxconcrete.sensor\_definition.strain\_sensor module
--------------------------------------------------------

Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ dependencies = [
"pint",
"gmsh",
"jsonschema",
"scipy",
]
description = "Implementation of structural problems for concrete structures using FEniCSx"
license = {file = "LICENSE"}
Expand Down
74 changes: 73 additions & 1 deletion src/fenicsxconcrete/experimental_setup/simple_cube.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ def __init__(self, parameters: dict[str, pint.Quantity] | None = None) -> None:
default_p["height"] = 1 * ureg("m")
default_p["width"] = 1 * ureg("m")
default_p["length"] = 1 * ureg("m")
default_p["T_0"] = ureg.Quantity(20.0, ureg.degC)
default_p["T_bc"] = ureg.Quantity(20.0, ureg.degC)

default_p.update(parameters)

Expand All @@ -59,7 +61,6 @@ def default_parameters() -> dict[str, pint.Quantity]:
setup_parameters["num_elements_width"] = 2 * ureg("")
setup_parameters["num_elements_height"] = 2 * ureg("")
setup_parameters["strain_state"] = "uniaxial" * ureg("")
setup_parameters["strain_state"] = "uniaxial" * ureg("")

return setup_parameters

Expand Down Expand Up @@ -99,6 +100,8 @@ def setup(self) -> None:

# initialize variable top_displacement
self.top_displacement = df.fem.Constant(domain=self.mesh, c=0.0) # applied via fkt: apply_displ_load(...)
self.use_body_force = False
self.temperature_bc = df.fem.Constant(domain=self.mesh, c=self.p["T_bc"])

def create_displacement_boundary(self, V: df.fem.FunctionSpace) -> list[df.fem.bcs.DirichletBCMetaClass]:
"""Defines the displacement boundary conditions
Expand Down Expand Up @@ -179,3 +182,72 @@ def apply_displ_load(self, top_displacement: pint.Quantity | float) -> None:
"""
top_displacement.ito_base_units()
self.top_displacement.value = top_displacement.magnitude

def apply_temp_bc(self, T_bc: pint.Quantity | float) -> None:
"""Updates the applied temperature boundary condition
Args:
T_bc1: Temperature of the top boundary in degree Celsius
"""
T_bc.ito_base_units()
self.temperature_bc.value = T_bc.magnitude
self.p["T_bc"] = T_bc.magnitude

def apply_body_force(self) -> None:
self.use_body_force = True

def create_temperature_bcs(self, V: df.fem.FunctionSpace) -> list[df.fem.bcs.DirichletBCMetaClass]:
"""defines empty temperature boundary conditions (to be done in child)
this function is abstract until there is a need for a material that does need a temperature boundary
once that is required, just make this a normal function that returns an empty list
Args:
V: function space
Returns:
a list with temperature boundary conditions
"""

def full_boundary(x):
if self.p["dim"] == 2:
return (
self.boundary_bottom()(x)
| self.boundary_left()(x)
| self.boundary_right()(x)
| self.boundary_top()(x)
)
elif self.p["dim"] == 3:
return (
self.boundary_back()(x)
| self.boundary_bottom()(x)
| self.boundary_front()(x)
| self.boundary_left()(x)
| self.boundary_right()(x)
| self.boundary_top()(x)
)

bc_generator = BoundaryConditions(self.mesh, V)
bc_generator.add_dirichlet_bc(
self.temperature_bc,
boundary=full_boundary,
method="geometrical",
entity_dim=self.mesh.topology.dim - 1,
)
return bc_generator.bcs

def create_body_force(self, v: ufl.argument.Argument) -> ufl.form.Form | None:
# TODO: The sign of the body force is not clear.

if self.use_body_force:
force_vector = np.zeros(self.p["dim"])
force_vector[-1] = self.p["rho"] * self.p["g"] # works for 2D and 3D

f = df.fem.Constant(self.mesh, force_vector)
L = ufl.dot(f, v) * ufl.dx

return L
else:
return None
3 changes: 2 additions & 1 deletion src/fenicsxconcrete/finite_element_problem/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from .base_material import MaterialProblem
from .base_material import MaterialProblem, QuadratureFields, SolutionFields
from .concrete_am import ConcreteAM, ConcreteThixElasticModel
from .concrete_thermo_mechanical import ConcreteThermoMechanical
from .linear_elasticity import LinearElasticity
8 changes: 6 additions & 2 deletions src/fenicsxconcrete/finite_element_problem/base_material.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ class QuadratureFields:
strain: ufl.core.expr.Expr | df.fem.Function | None = None
degree_of_hydration: ufl.core.expr.Expr | df.fem.Function | None = None
damage: ufl.core.expr.Expr | df.fem.Function | None = None
compressive_strength: ufl.core.expr.Expr | df.fem.Function | None = None
tensile_strength: ufl.core.expr.Expr | df.fem.Function | None = None
youngs_modulus: ufl.core.expr.Expr | df.fem.Function | None = None
yield_values: ufl.core.expr.Expr | df.fem.Function | None = None


class MaterialProblem(ABC, LogMixin):
Expand Down Expand Up @@ -161,7 +165,7 @@ def delete_sensor(self) -> None:
del self.sensors
self.sensors = self.SensorDict()

def update_time(self):
def update_time(self) -> None:
"""update time"""
self.time += self.p["dt"]

Expand Down Expand Up @@ -227,7 +231,7 @@ class SensorDict(dict):
When to sensors with the same name are defined, the next one gets a number added to the name
"""

def __getattr__(self, key):
def __getattr__(self, key: str): # -> BaseSensor:
return self[key]

def __setitem__(self, initial_key: str, value: BaseSensor) -> None:
Expand Down
Loading

0 comments on commit 98ccd2c

Please sign in to comment.