学习中心

Solving Transient Models That Have Inconsistent Initial Values


When solving a transient (i.e., time-dependent) study in COMSOL Multiphysics®, it is important to have your model set up so that the initial conditions are consistent with the loads and boundary conditions. This is important for any time-dependent model, but it is especially notable when performing transient fluid flow studies. In this article, we will explain why such consistency is important, its impact on your model, and the different approaches that you can use to solve the transient model equations when you have inconsistent initial values.

Background

To illustrate with context why it is necessary for the initial values of your model to be consistent with the loads and boundary conditions, let us use an example. A simplefluid flow modelis represented below, consisting of a 2D channel that is 3 meters long and 1 meter wide, where the left boundary is the inlet and the right boundary is the outlet. We want to solve for the laminar flow of a fluid through a channel. The fluid has a density of 1 kg/m3and a viscosity of 0.01 Pa·s. A velocity of 1 m/s is specified at the inlet, and a zero-pressure boundary condition is applied to the outlet.

A diagram of laminar fluid flow through a channel from left to right, with a label on the left that says, A diagram of the fluid flow example model.

These boundary conditions lead to a mismatch between the value of the velocity at the inlet (u = 1 m/s) and the initial value of the velocity (u = 0 m/s) in the channel. This is referred to asinconsistent initial values.

A screenshot of the COMSOL Multiphysics UI showing the settings for the sample model's Inlet boundary condition. A screenshot of the COMSOL Multiphysics UI showing the settings for the sample model's Inlet boundary condition. The model setup for our example in the software, with the settings for the Inlet boundary condition displayed.


A screenshot of the COMSOL Multiphysics UI showing the default settings for the Initial Values node. A screenshot of the COMSOL Multiphysics UI showing the default settings for the Initial Values node. The defaultInitial Values node with the default settings.


When your model has inconsistent initial values, you may observe the solver taking very small time steps or ending the computation and reporting an error message like the following:

Failed to find consistent initial values.
Last time step is not converged.

A screenshot of a Time-Dependent Solver error message that says,
An error message stating the source of the error that prohibited the model computation from completing.

The COMSOL Multiphysics®software will, by default, attempt to reconcile inconsistent initial values by taking a small time step that is a fraction of the initial time step using a backward Euler method. The initial time step is by default determined based on the total simulation time span. However, it is also possible tospecify the initial time stepand change the fraction of the initial step used by the backward Euler method — a backward differentiation formula (BDF) method — for the consistent initialization. These settings will affect the results of the consistent initialization procedure.

A screenshot of the COMSOL Multiphysics Settings window for a Time-Dependent Solver, with the default initial step, consistent initialization, and fraction of initial step for backward Euler settings outlined in red.
TheSettingswindow showing the default settings for theTime-Dependent Solver.

The consistent initialization may fail if the backward Euler step is too large or if the boundary conditions in your model are inconsistent with each other or the physics in your model. More commonly, the results may be very far from what is expected, and the solver will likely need to take very small time steps at the beginning of the simulation to evolve from the initial solution. This is undesirable because it can lead to long solution times.

In many cases this consistent initialization is not strictly needed, and it might be better to turn it off to ensure that your model smoothly ramps up all loads and boundary conditions from consistent initial values. In this article, we will present you with two ways to do so. The approaches we recommend for computing transient models with inconsistent initial values are the following:

  1. Initialize the time-dependent study with aStationarystudy step
  2. Ramp up the boundary conditions over time

Please note that if your boundary conditions are truly inconsistent, then the resolutions in this article will not be applicable. Always check the applied loads and boundary conditions in your model carefully for consistency. The recommendations we outline here are only applicable to well-posed problems, so it is important that your model meet that threshold first.

Approach 1: Initializing Time-Dependent Studies with Stationary Studies

The first approach you can use to solve a time-dependent model with inconsistent initial values is to initialize your transient study with a stationary study. There are a couple of ways that this can be done, as are described below.

Using Multiple Steps

A single study can include multiple study steps. By default, the results of each study step are passed on to the following study step as its initial values. When aStationarystudy step is added before aTime Dependentstudy step, the study will solve first for the fields under the steady-state assumption and then use these computations to provide consistent initial values for the transient step, overriding the initial values specified within theInitial Valuesnode in the physics interface. As long as the two steps are within the same study, as shown in the screenshot below, no other changes are needed. When the study is solved, both steps will be recomputed.

A screenshot of the COMSOL Multiphysics UI showing a stationary study step preceding a time-dependent study step in the model tree.
AStationarystudy step is used to compute the initial values for the transient study step.

You can see this multistep approach firsthand in the attached model file for the fluid flow example introduced earlier.

Using Multiple Studies

Values of Dependent Variables Settings Section

It is also possible to split the analysis into two separate studies. In this way, theStationarystudy step and theTime Dependentstudy step are each added under two different studies. This setup requires that theValues of Dependent Variablessection in the settings for theTime Dependentstudy step are set to refer to the results of the stationary study, as shown in the screenshot below.

A screenshot of the COMSOL Multiphysics UI showing the initial values in the Settings window for a Time Dependent study step that has been added under a second study after an initial stationary study has been implemented.
The settings for theTime Dependentstudy step node, which uses the initial values computed from the previous stationary study.

You can explore how this version of the approach was implemented for the fluid flow example in the model file includedhere.

Although this strategy is available, it does come with a number of drawbacks:

  1. First, depending on the problem you are modeling, a stationary solution might not exist. This is particularly common for fluid flow models near the onset of turbulence, where steady boundary conditions result in an unsteady (time-varying) flow field. It can also be the case that a steady-state solution for your model is numerically difficult to find. Please see our resource discussing how toimprove the convergence of nonlinear, stationary modelsto learn how to address such cases.
  2. Second, the objective of the transient model may be to investigate the startup behavior as the system evolves from the at-rest state.

In either case, use the second method, described below.

Using the withsol Operator

When splitting the analysis into two separate studies, another option for referring to the results of the stationary study would be to use thewithsoloperator. Thewithsol operatorenables you to extract and use the solution from one study as input for another study. It is equivalent to making the changes in theValues of Dependent Variablessection of a study step's settings, discussed in the preceding section.

In theInitial Valuesnode, we can enter the appropriate syntax for using thewithsoloperator, formatted as:withsol('tag',expr). For a split-study analysis, where'tag'is, we enter'sol1'to refer to the stationary study's solver sequence, and forexpr, we enter the appropriate physics variable (ufor thex-component of the fluid flow velocity field,vfor they-component of the fluid flow velocity field, orpfor the pressure).

A screenshot of the COMSOL Multiphysics UI showing the withsol operator in the settings of the Initial Values node.
The settings for theInitial Valuesnode, wherein thewithsol _operator is used to refer to the solution for the stationary study.

More details andexamples of using thewithsoloperatorare available in our Learning Center article on this topic.

Approach 2: Ramping Up Boundary Conditions over Time

The second approach you can use to compute a time-dependent model with inconsistent initial values is to ramp up the loads and boundary conditions in your model over time.

The loads and boundary conditions in a transient model can be ramped up from values that are consistent with the initial values. The most common case is an at-equilibrium system, where the initial values are zero everywhere. The COMSOL Multiphysics®software includes several built-in functions that you can use to transition from these initial values to other values. In this example, we use the built-inStepfunction with smoothing, as shown in the screenshot below.

A screenshot of the COMSOL Multiphysics UI showing the Step function settings with smoothing and a function plot that shows the ramp up from the initial values. A screenshot of the COMSOL Multiphysics UI showing the Step function settings with smoothing and a function plot that shows the ramp up from the initial values.
The settings of theStep function with smoothing.


There are several other functions that also include aSmoothingoption, as describedhere, where we discuss the modeling of step transitions. By default, these will all have a time derivative equal to zero at the start of the smoothing zone, which is helpful because there will be no abrupt step or change and it allows for a gradual transition.

We can use the smoothedStepfunction to modify the loads and boundary conditions of our transient fluid flow model, as shown in the screenshot below. The corresponding model file can be downloadedhere.

A screenshot of the COMSOL Multiphysics UI showing the Settings window and a function plot of the smoothed Step function. A screenshot of the COMSOL Multiphysics UI showing the Settings window and a function plot of the smoothed Step function.
The smoothedStep function is used to ramp up the boundary condition.


In the study for your model, you will need to choose a time span for the smoothing that is physically realistic for the problem at hand. However, instead of using a smoothing that is physically realistic, it may be reasonable to introduce a very gradual ramping, since this may solve more easily.

A screenshot of the COMSOL Multiphysics UI showing the settings for a gradual ramping using the smoothed Step function.
The settings for theTime Dependentstudy step. A short time range (from 0 to 0.1 seconds) with a smaller step size (0.01 seconds) is used where ourStepfunction is defined and ramping up the velocity at theInletboundary condition in the model.

Note that not all problems will require this type of smoothing. Some problems, particularly heat transfer problems that do not involve convection, can be solved with step changes to the loads. If these step changes happen during the simulation time span, you should use theEventsinterface to accurately model these cases, as describedhere, where we discuss solving models with pulsed loads in time.

Further Learning

Using either of the above techniques to solve transient models with inconsistent initial values should resolve the issue of finding a consistent initialization, and you should not have to alter the study settings in your model. However, if you find that you still are encountering issues with convergence, this could be due to a few reasons:

  • The model is not meshed finely enough. In this case, you should consider a mesh refinement study, which you can learn abouthere.
  • The model is highly nonlinear. In this case, you should consider changing the solver configuration settings, which you can learn abouthere.

请提交与此页面相关的反馈,或点击此处联系技术支持

Baidu
map