-
Notifications
You must be signed in to change notification settings - Fork 265
Kratos For Dummies: Transient non linear heat transfer
In this second part we will modify the element and the solver in order to compute a transient non-linear problem, in other words, compute the dynamic contribution of the element. We will use the tools already available on the Kratos framework (or KratosCore), like the Newton-Rahpson strategy, the convergence criterion and the BDF scheme.
In order to accommodate the interoperability with other applicatiion in Kratos we will show how to integrate the already developed solver into the common interface for all the solvers. Finally all this will be integrated in one analysis stage file, that will replace the main script file. Helping in the future the development of coupled solver.
Additionally, you can see all the tools, processes, classes, variables, etc... available on the pỳthon interface of the KratosCore here.
- Adding dynamic contribution to the element
- Updating solver to Non-linear and transient
- Integrate into an analysis stage
The following wrapper for the convergence criteria is already available in the Kratos/kratos/python_scripts/base_convergence_criteria_factory.py. Like we are not considering any additional convergence criteria to the ones available on the framework we can work taking into account just these.
from __future__ import print_function, absolute_import, division # makes KratosMultiphysics backward compatible with python 2.6 and 2.7
# Importing the Kratos Library
import KratosMultiphysics
# Convergence criteria class
class ConvergenceCriteriaFactory(object):
def __init__(self, convergence_criterion_parameters):
# Note that all the convergence settings are introduced via a Kratos parameters object.
D_RT = convergence_criterion_parameters["solution_relative_tolerance"].GetDouble()
D_AT = convergence_criterion_parameters["solution_absolute_tolerance"].GetDouble()
R_RT = convergence_criterion_parameters["residual_relative_tolerance"].GetDouble()
R_AT = convergence_criterion_parameters["residual_absolute_tolerance"].GetDouble()
echo_level = convergence_criterion_parameters["echo_level"].GetInt()
convergence_crit = convergence_criterion_parameters["convergence_criterion"].GetString()
if(echo_level >= 1):
KratosMultiphysics.Logger.PrintInfo("::[ConvergenceCriterionFactory]:: ", "CONVERGENCE CRITERION : " +
convergence_criterion_parameters["convergence_criterion"].GetString())
if(convergence_crit == "solution_criterion"):
self.convergence_criterion = KratosMultiphysics.DisplacementCriteria(D_RT, D_AT)
self.convergence_criterion.SetEchoLevel(echo_level)
elif(convergence_crit == "residual_criterion"):
self.convergence_criterion = KratosMultiphysics.ResidualCriteria(R_RT, R_AT)
self.convergence_criterion.SetEchoLevel(echo_level)
elif(convergence_crit == "and_criterion"):
Displacement = KratosMultiphysics.DisplacementCriteria(D_RT, D_AT)
Displacement.SetEchoLevel(echo_level)
Residual = KratosMultiphysics.ResidualCriteria(R_RT, R_AT)
Residual.SetEchoLevel(echo_level)
self.convergence_criterion = KratosMultiphysics.AndCriteria(Residual, Displacement)
elif(convergence_crit == "or_criterion"):
Displacement = KratosMultiphysics.DisplacementCriteria(D_RT, D_AT)
Displacement.SetEchoLevel(echo_level)
Residual = KratosMultiphysics.ResidualCriteria(R_RT, R_AT)
Residual.SetEchoLevel(echo_level)
self.convergence_criterion = KratosMultiphysics.OrCriteria(Residual, Displacement)
else:
err_msg = "The requested convergence criterion \"" + convergence_crit + "\" is not available!\n"
err_msg += "Available options are: \"solution_criterion\", \"residual_criterion\", \"and_criterion\", \"or_criterion\""
raise Exception(err_msg)
Now if we want to integrate it into the solver, we just need to add the following to the solver:
def _create_convergence_criterion(self):
import base_convergence_criteria_factory as convergence_criteria_factory
convergence_criterion = convergence_criteria_factory.ConvergenceCriteriaFactory(self._get_convergence_criterion_settings())
return convergence_criterion.convergence_criterion
- Getting Kratos (Last compiled Release)
- Compiling Kratos
- Running an example from GiD
- Kratos input files and I/O
- Data management
- Solving strategies
- Manipulating solution values
- Multiphysics
- Video tutorials
- Style Guide
- Authorship of Kratos files
- Configure .gitignore
- How to configure clang-format
- How to use smart pointer in Kratos
- How to define adjoint elements and response functions
- Visibility and Exposure
- Namespaces and Static Classes
Kratos structure
Conventions
Solvers
Debugging, profiling and testing
- Compiling Kratos in debug mode
- Debugging Kratos using GDB
- Cross-debugging Kratos under Windows
- Debugging Kratos C++ under Windows
- Checking memory usage with Valgind
- Profiling Kratos with MAQAO
- Creating unitary tests
- Using ThreadSanitizer to detect OMP data race bugs
- Debugging Memory with ASAN
HOW TOs
- How to create applications
- Python Tutorials
- Kratos For Dummies (I)
- List of classes and variables accessible via python
- How to use Logger
- How to Create a New Application using cmake
- How to write a JSON configuration file
- How to Access DataBase
- How to use quaternions in Kratos
- How to do Mapping between nonmatching meshes
- How to use Clang-Tidy to automatically correct code
- How to use the Constitutive Law class
- How to use Serialization
- How to use GlobalPointerCommunicator
- How to use PointerMapCommunicator
- How to use the Geometry
- How to use processes for BCs
- How to use Parallel Utilities in futureproofing the code
- Porting to Pybind11 (LEGACY CODE)
- Porting to AMatrix
- How to use Cotire
- Applications: Python-modules
- How to run multiple cases using PyCOMPSs
- How to apply a function to a list of variables
- How to use Kratos Native sparse linear algebra
Utilities
Kratos API
Kratos Structural Mechanics API