# Example 06 : Transient Analysis

## Problem Statement

We consider the transient diffusion equation on the 3D domain : find such that , on the bottom, on the top and with on the remaining boundaries. The initial condition is everywhere except on the top boundary where .

The weak form of this equation, in inner-product notation, is given by: , where are the test functions and is the finite element solution.

## Constructing the Problem

First, we need a transient term to for our residual. We can create a time-dependent residual term by inheriting from the TimeDerivative class. For this example, we create a constant-scalable time-dependent residual along the lines of kernels created in the earlier examples:

#include "ExampleTimeDerivative.h"

#include "Material.h"

registerMooseObject("ExampleApp", ExampleTimeDerivative);

template <>
InputParameters
validParams<ExampleTimeDerivative>()
{
InputParameters params = validParams<TimeDerivative>();
return params;
}

ExampleTimeDerivative::ExampleTimeDerivative(const InputParameters & parameters)
: TimeDerivative(parameters),
_time_coefficient(getParam<Real>("time_coefficient"))
{
}

Real
ExampleTimeDerivative::computeQpResidual()
{
return _time_coefficient * TimeDerivative::computeQpResidual();
}

Real
ExampleTimeDerivative::computeQpJacobian()
{
return _time_coefficient * TimeDerivative::computeQpJacobian();
}

(examples/ex06_transient/src/kernels/ExampleTimeDerivative.C)

The input file for this is very similar to the simple diffusion input file from example 1. We need to add the time derivative residual contribution:

[Kernels]
[./diff]
type = Diffusion
variable = diffused
[../]

# Include our time derivative here
[./euler]
type = ExampleTimeDerivative
variable = diffused
time_coefficient = 20.0
[../]
[]

(examples/ex06_transient/ex06.i)

And finally, we need to specify some transient related parameters:

[Executioner]
type = Transient # Here we use the Transient Executioner (instead of steady)
solve_type = 'PJFNK'
num_steps = 75 # Run for 75 time steps, solving the system each step.
dt = 1 # each time step will have duration "1"
[]

(examples/ex06_transient/ex06.i)

There are many more options available that are described in the Transient Executioner documentation. It is also common to use more sophisticated ways for time-stepping through simulations. Example 16 goes over some of this and details about specific time stepping schemes are provided in the Timestepper System documentation.

## Outputs

Here are solution snapshots from the beginning and end times from running ex06-opt -i ex06.i: