Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NEML integration #60

Merged
merged 8 commits into from
Mar 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ temp_print_trace.*
*.poly
*.mpx
*.btr
*.xml
*.gmv
*.plt
*.slh
Expand Down
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[submodule "contrib/neml"]
path = contrib/neml
url = ../../Argonne-National-Laboratory/neml.git
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be a remote URL? This looks like you added a local repo as a submodule.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doing it this way gets it through either ssh or https, using whatever protocol you used to clone the repository. I think this is how we grab the libmesh submodule in moose.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works because they’re both hosted on GitHub.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, cool. I guess I learned something new: Submodule urls can be relative to the superproject’s default remote repository (the remote of the remote-tracking branch of the current branch!)

https://git-scm.com/docs/git-submodule

ignore = untracked
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ POROUS_FLOW := no

include $(MOOSE_DIR)/modules/modules.mk
###############################################################################
BLACKBEAR_DIR := $(CURDIR)

# dep apps
APPLICATION_DIR := $(CURDIR)
Expand Down
1 change: 1 addition & 0 deletions blackbear.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include $(BLACKBEAR_DIR)/contrib/neml.mk
1 change: 1 addition & 0 deletions contrib/neml
Submodule neml added at c6c2d0
33 changes: 33 additions & 0 deletions contrib/neml.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
neml_DIR := $(BLACKBEAR_DIR)/contrib/neml

ifneq ($(wildcard $(neml_DIR)/CMakeLists.txt),)

#Exclude all the files with _wrap in the name because they are drivers for testing
#that are not needed and have additional dependencies.
neml_srcfiles := $(shell find $(neml_DIR)/src -name "*.cxx" | grep -v _wrap)
neml_objects += $(patsubst %.cxx,%.$(obj-suffix),$(neml_srcfiles))
neml_LIB := $(neml_DIR)/libneml-$(METHOD).la
neml_includes := $(neml_DIR)/src
neml_dep_includes := -I$(neml_DIR)/rapidxml

$(APPLICATION_DIR)/lib/libblackbear-$(METHOD).la: $(neml_LIB)

$(neml_LIB): $(neml_objects)
@echo "Linking Library "$@"..."
@$(libmesh_LIBTOOL) --tag=CC $(LIBTOOLFLAGS) --mode=link --quiet \
$(libmesh_CC) $(libmesh_CFLAGS) -o $@ $(neml_objects) $(libmesh_LDFLAGS) $(EXTERNAL_FLAGS) -rpath $(neml_DIR)
@$(libmesh_LIBTOOL) --mode=install --quiet install -c $(neml_LIB) $(neml_DIR)

$(neml_DIR)/src/%.$(obj-suffix) : $(neml_DIR)/src/%.cxx
@echo "Compiling C++ (in "$(METHOD)" mode) "$<"..."
@$(libmesh_LIBTOOL) --tag=CXX $(LIBTOOLFLAGS) --mode=compile --quiet \
$(libmesh_CXX) $(libmesh_CPPFLAGS) $(ADDITIONAL_CPPFLAGS) $(libmesh_CXXFLAGS) $(neml_dep_includes) $(app_INCLUDES) $(libmesh_INCLUDE) -w -DHAVE_CONFIG_H -MMD -MP -MF [email protected] -MT $@ -c $< -o $@

ADDITIONAL_INCLUDES += -I$(neml_includes)
ADDITIONAL_LIBS += -L$(neml_DIR) -lneml-$(METHOD)
ADDITIONAL_CPPFLAGS += -DNEML_ENABLED

else
$(info WARNING: Not building with NEML because contrib/neml submodule is not present)
$(info See https://github.com/Argonne-National-Laboratory/neml/blob/dev/INSTALL.md)
endif
32 changes: 32 additions & 0 deletions doc/content/source/materials/NEMLStress.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# NEML Stress

!syntax description /Materials/NEMLStress

# Stress Calculator Based on NEML Constitutive Models

This material model provides an interface to the constitutive models for structural materials provided by the [Nuclear Engineering Material model Library (NEML)](https://github.com/Argonne-National-Laboratory/neml) developed by Argonne National Laboratory. This is a general interface to all of the models provided by that library, which are documented in detail in the [NEML documentation](https://neml.readthedocs.io/en/stable/).

NEML permits the definition of complex material constitutive models, the details of which are defined in an XML file that is independent of the MOOSE input file. The required inputs for this model on the MOOSE side simply provide the location of the XML file, which contains a database of potentially multiple material models, and the name of the model within that database to be used. This model computes the stress, elasticity tensor, and material Jacobian.

Using this model requires that the NEML source code is present, and that the prerequisite libraries are available. NEML is provided as a submodule in BlackBear under the directory `blackbear/contrib/neml`. The up-to-date version of the NEML submodule is obtained using:
```
git submodule init
git submodule update
```
in the `blackbear` directory.

NEML is compiled using the MOOSE build system, so no separate compilation step is required to build the library. However, NEML has dependencies on the BOOST library that is not present in the default MOOSE environment.

To build with BOOST, one must simply load the `boost` module provided with MOOSE:
```
module load advanced_modules boost
```
and add the `--with-boost` option to the `update_and_rebuild_libmesh.sh` script when compiling libMesh to instruct it to use the full BOOST instalation provided by the `boost` module, rather than the subset of BOOST that is distributed with libmesh.

!syntax parameters /Materials/NEMLStress

!syntax inputs /Materials/NEMLStress

!syntax children /Materials/NEMLStress

!bibtex bibliography
17 changes: 17 additions & 0 deletions doc/content/source/materials/NEMLThermalExpansionEigenstrain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# NEML Thermal Expansion Eigenstrain

!syntax description /Materials/NEMLThermalExpansionEigenstrain

# Thermal Eigenstrain Obtained from NEML

This material model provides an interface to use the [Nuclear Engineering Material model Library (NEML)](https://github.com/Argonne-National-Laboratory/neml) developed by Argonne National Laboratory to provide thermal expansion eigenstrains. This model would typically be used together with the [NEMLStress](NEMLStress.md) model, the documentation of which provides more details on integration with that library.

NEML permits the definition of complex material constitutive models, the details of which are defined in an XML file that is independent of the MOOSE input file. The required inputs for this model on the MOOSE side simply provide the location of the XML file, which contains a database of potentially multiple material models, and the name of the model within that database to be used. This model computes the eigenstrain induced by thermal expansion.

!syntax parameters /Materials/NEMLThermalExpansionEigenstrain

!syntax inputs /Materials/NEMLThermalExpansionEigenstrain

!syntax children /Materials/NEMLThermalExpansionEigenstrain

!bibtex bibliography
92 changes: 92 additions & 0 deletions include/materials/NEMLStress.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
/****************************************************************/
/* DO NOT MODIFY THIS HEADER */
/* BlackBear */
/* */
/* (c) 2017 Battelle Energy Alliance, LLC */
/* ALL RIGHTS RESERVED */
/* */
/* Prepared by Battelle Energy Alliance, LLC */
/* Under Contract No. DE-AC07-05ID14517 */
/* With the U. S. Department of Energy */
/* */
/* See COPYRIGHT for full restrictions */
/****************************************************************/

#ifndef NEMLSTRESS_H
#define NEMLSTRESS_H

#include "ComputeStressBase.h"

#include "neml_interface.h"

class NEMLStress;

template <>
InputParameters validParams<NEMLStress>();

class NEMLStress : public ComputeStressBase
{
public:
NEMLStress(const InputParameters & parameters);

virtual void computeQpStress() override;
virtual void initQpStatefulProperties() override;

protected:
/// File name of the NEML XML database
FileName _fname;
/// Model name in NEML XML database
std::string _mname;
/// NEML model
std::unique_ptr<neml::NEMLModel> _model;
/// History variables used by NEML model
///@{
MaterialProperty<std::vector<Real>> & _hist;
const MaterialProperty<std::vector<Real>> & _hist_old;
///@}
/// Old mechanical strain
const MaterialProperty<RankTwoTensor> & _mechanical_strain_old;
/// Old stress
const MaterialProperty<RankTwoTensor> & _stress_old;
/// Strain energy
///@{
MaterialProperty<Real> & _energy;
const MaterialProperty<Real> & _energy_old;
///@}
/// Dissipation
///@{
MaterialProperty<Real> & _dissipation;
const MaterialProperty<Real> & _dissipation_old;
///@}
/// Coupled temperature variable (defaults to zero if not specified)
///@{
const VariableValue & _temperature;
const VariableValue & _temperature_old;
///@}
/// Inelastic strain tensor
MaterialProperty<RankTwoTensor> & _inelastic_strain;

/**
* Translates a RankTwoTensor object to a NEML tensor stored in a vector
* format.
* @param in RankTwoTensor to be translated
* @param out NEML vector output
**/
void RankTwoTensorToNeml(const RankTwoTensor & in, double * const out);

/**
* Translates a NEML tensor stored in vector format to a RankTwoTensor.
* @param in NEML vector to be translated
* @param out RankTwoTensor output
**/
void NemlToRankTwoTensor(const double * const in, RankTwoTensor & out);

/**
* Translates a NEML elasticity tensor to a RankFourTensor.
* @param in NEML elasticity tensor to be translated
* @param out RankFourTensor output
**/
void NemlToRankFourTensor(const double * const in, RankFourTensor & out);
};

#endif // NEMLSTRESS_H
58 changes: 58 additions & 0 deletions include/materials/NEMLThermalExpansionEigenstrain.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/****************************************************************/
/* DO NOT MODIFY THIS HEADER */
/* BlackBear */
/* */
/* (c) 2017 Battelle Energy Alliance, LLC */
/* ALL RIGHTS RESERVED */
/* */
/* Prepared by Battelle Energy Alliance, LLC */
/* Under Contract No. DE-AC07-05ID14517 */
/* With the U. S. Department of Energy */
/* */
/* See COPYRIGHT for full restrictions */
/****************************************************************/

#ifndef NEMLTHERMALEXPANSIONEIGENSTRAIN_H
#define NEMLTHERMALEXPANSIONEIGENSTRAIN_H

#include "ComputeThermalExpansionEigenstrainBase.h"

#include "neml_interface.h"

class NEMLThermalExpansionEigenstrain;

template <>
InputParameters validParams<NEMLThermalExpansionEigenstrain>();

/**
* NEMLThermalExpansionEigenstrain computes the thermal expansion
* strain from the instantaneous CTE provided by a NEML model
*/
class NEMLThermalExpansionEigenstrain : public ComputeThermalExpansionEigenstrainBase
{
public:
NEMLThermalExpansionEigenstrain(const InputParameters & parameters);
virtual void initQpStatefulProperties() override;

protected:
virtual void computeThermalStrain(Real & thermal_strain, Real & instantaneous_cte) override;

protected:
/// File name of the NEML XML database
FileName _fname;
/// Model name in NEML XML database
std::string _mname;
/// NEML model
std::unique_ptr<neml::NEMLModel> _model;

/// Thermal strain
///@{
MaterialProperty<Real> & _tstrain;
const MaterialProperty<Real> & _tstrain_old;
///@}

/// Old state of the coupled temperature
const VariableValue & _temperature_old;
};

#endif // NEMLTHERMALEXPANSIONEIGENSTRAIN_H
Loading