Skip to content

Commit

Permalink
add set to default parameters in doc examples
Browse files Browse the repository at this point in the history
  • Loading branch information
aradermacher committed Sep 19, 2023
1 parent 0674cfb commit c6cd2fa
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 25 deletions.
3 changes: 2 additions & 1 deletion docs/examples/3_point_bending.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# Setting up the Beam
# -------------------
# First, initialize the setup for the simply supported beam with a distributed load.
# Define the geometry, the mesh, and the load.
# Define the geometry, the mesh, and the load. Not defined parameters are set to default values (from class function default_parameters).
# Note, all parameters must be pint objects:

parameters = {}
Expand All @@ -36,6 +36,7 @@
# Initializing the Linear Elasticity Problem
# ------------------------------------------
# Second, initialize the linear elastic problem using the setup object and further material parameters:
# Again not defined parameters are set to default values (from class function default_parameters).

parameters["rho"] = 7750 * ureg("kg/m^3")
parameters["E"] = 210e9 * ureg("N/m^2")
Expand Down
1 change: 1 addition & 0 deletions docs/examples/cylinder.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
# * `mesh_density` (mesh density) in 1/m
#
# The parameters must be defined as `pint` objects
# Parameters required but not defined are set to default values (from class function default_parameters).
#
# Example code
# ------------
Expand Down
2 changes: 0 additions & 2 deletions src/fenicsxconcrete/experimental_setup/base_experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,10 @@ def __init__(self, parameters: dict[str, pint.Quantity]) -> None:
# check if units are compatible
dim_given = parameters[key].dimensionality
dim_default = default_p[key].dimensionality
print(f"check {key} {dim_given} {dim_default}")
if dim_given != dim_default:
raise ValueError(
f"given units for {key} are not compatible with default units: {dim_given} != {dim_default}"
)
print(f"for the following parameters, the default values are used: {keys_set_default}")
self.logger.info(f"for the following parameters, the default values are used: {keys_set_default}")

# as attribute
Expand Down
12 changes: 1 addition & 11 deletions src/fenicsxconcrete/finite_element_problem/base_material.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,23 +112,13 @@ def __init__(
# check if units are compatible
dim_given = parameters[key].dimensionality
dim_default = default_p[key].dimensionality
print(f"check {key} {dim_given} {dim_default}")
if dim_given != dim_default:
raise ValueError(
f"given units for {key} are not compatible with default units: {dim_given} != {dim_default}"
)
print(f"for the following parameters, the default values are used: {keys_set_default}")
self.logger.info(f"for the following parameters, the default values are used: {keys_set_default}")

# # setting up default material parameters
# default_fem_parameters = Parameters()
# default_fem_parameters["g"] = 9.81 * ureg("m/s^2")
# default_fem_parameters["dt"] = 1.0 * ureg("s")
#
# # adding experimental parameters to dictionary to combine to one
# default_fem_parameters.update(self.experiment.parameters)
# # update with input parameters
# default_fem_parameters.update(parameters)
# set parameters as attribute
self.parameters = setup_parameters
# remove units for use in fem model
self.p = self.parameters.to_magnitude()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,10 @@ def default_parameters() -> tuple[Experiment, dict[str, pint.Quantity]]:
"evolution_ft": "True" * ureg(""),
"dt": 1.0 * ureg("s"),
}
default_parameters["E_act"] = 5653.0 * default_parameters["igc"] * ureg("J/mol")
print("CHECK", default_parameters["E_act"])
default_parameters["E_act"] = (
5653.0 * default_parameters["igc"].magnitude * ureg("J/mol")
) # TODO Check with Sjard

return experiment, default_parameters

def compute_residuals(self) -> None:
Expand Down
5 changes: 0 additions & 5 deletions tests/finite_element_problem/test_thermo_mechanical_cube.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,3 @@ def test_hydration_with_body_forces(dim: int):
np.testing.assert_allclose(data["t"], t_list)
np.testing.assert_allclose(data["doh"].flatten(), np.array(doh_sensor.data).flatten(), rtol=1e-4)
np.testing.assert_allclose(data["E"].flatten(), np.array(E_sensor.data).flatten(), rtol=1e-4)


# main
if __name__ == "__main__":
test_hydration_with_body_forces(3)
8 changes: 4 additions & 4 deletions tests/finite_element_problem/test_thixotropy_uniaxial.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,8 @@ def check_disp_case(problem: ConcreteAM, dt: pint.Quantity, E_o_time: list[float
assert E_o_time[-1] == pytest.approx(E_end)


if __name__ == "__main__":
# if __name__ == "__main__":
#
# test_disp(2, 2)

test_disp(2, 2)

# test_disp(3, 1)
# test_disp(3, 1)

0 comments on commit c6cd2fa

Please sign in to comment.