Skip to content

Kratos For Dummies: Transient non linear heat transfer

Vicente Mataix Ferrándiz edited this page Jul 24, 2018 · 21 revisions

Overview

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.

Contents

  1. Adding dynamic contribution to the element
  2. Updating solver to Non-linear and transient
    1. Adapt our solver to the common solver interface
    2. Creating a wrapper of convergence criterion
    3. Adding the transient scheme
    4. Using the Newton-Rahpson strategy
  3. Integrate into an analysis stage

Adding dynamic contribution to the element

Updating solver to Non-linear and transient

Adapt our solver to the common solver interface

Creating a wrapper of convergence criteria

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

Adding the transient scheme

Using the Newton-Rahpson strategy

Integrate into an analysis stage

Project information

Getting Started

Tutorials

Developers

Kratos structure

Conventions

Solvers

Debugging, profiling and testing

HOW TOs

Utilities

Kratos API

Kratos Structural Mechanics API

Clone this wiki locally