
Browse by Category
 All solutions
 ALE / Parameterized Geometry (1)
 Error Messages (82)
 Fluid Dynamics (2)
 General (12)
 Geometry (15)
 Import (16)
 Installation (61)
 Mesh (11)
 Multiphysics (1)
 Physics (11)
 Postprocessing (1)
 Solver (22)
 Structural Mechanics (3)
 User Models (1)
Solution Number:  1245 
Title:  Improving runtimes for transient models with step changes in loads 
Platform:  
Applies to:  All Products 
Versions:  All versions 
Categories:  Solver 
Keywords: 
Problem Description
I am solving a transient model which has loads that change instantaneously in time, but the solver is taking a very long time to compute the solution.
Solution
When solving a transient model, be aware that the default behavior of the solver is to adaptively choose a timestep size that will attempt to resolve all of the variations in the solution over time, to within the specified tolerances. The appropriate way to deal with this depends upon if the system can oscillate or not. That is, ask yourself if the governing equations involve first or second timederivatives of the solution. There is also the special case of the NavierStokes equations, although these equations do not directly contain a second timederivative the solutions can still oscillate in time.
Models involving governing equations with second timederivatives and fluid flow models
For these types of models, the solution will oscillate in response to abrupt changes in the load. For example, consider a tensioned guitar wire: When the wire is abruptly plucked, it will vibrate at its fundamental frequency, as well as at a number of higher overtones. Similarly, a rock dropped into a pond will lead to many large, and small, ripples in the surface. From a modeling point of view we may not actually be interested in all of the higher overtones, or small ripples, but the solver will still try to adjust the timestep to be small enough to capture these variations in time. Additionally, if there are any nonlinearities in the model, these can lead to higher harmonics being generated. Hence you may observe very slow solution times, and the mesh would need to be very fine to resolve these fast oscillations in space and time.
This slow solution time arises as a consequence of the input signal: An applied load or boundary condition that varies instantaneously in time can excite an infinite number of higher frequency variations in the solution fields. This becomes apparent when we take the Fourier Transform of a flat pulse in time, as shown in the image below. Note that the Fourier coefficients drop off rapidly, but never get to exactly zero. The solver will still be sensitive to some of this high frequency content.
A step load in time and its Fourier transform
The resolution is to smooth the input signal such to avoid abrupt changes. This is physically motivated, since most loads cannot truly change instantaneously in time. It is also reasonable from a modeling point of view: The high frequency content contains a relatively small fraction of the total energy of the system, and it likely of little practical interest. An example of such a smoothed input signal, as well as its Fourier transform, is shown in red in the image below. Note that the low frequency content of the signal is almost identical, but the smoothed signal has negligible higher frequency content past the a certain point, as compared to the original signal.
A smoothed step load in time (red curve) and its Fourier transform
The inbuilt Rectangle, Triangle, Step, Ramp and Waveform of Type Sawtooth, Square and Triangle all include the option to smooth the signal, as shown in the figure below. The Piecewise function also permits smoothing between intervals.
Smoothing of a function
Once you appropriately smooth all of your loading functions, you will also know the maximum possible frequency content of your excitation. This will let you choose the appropriate mesh, and you can manually adjust the timestep, as described in: Knowledge Base 1118: Resolving timedependent waves
See also:
Knowledge Base 1172: Solving time dependent CFD simulations
Knowledge Base 1240: Manually Setting the Scaling of Variables
Models involving governing equations with first timederivatives
The solution to these types of models will not oscillate in time with respect to a step change in loads. Practical examples include applying a step change in the heat load in a thermal model, or a change in the applied current in an electric currents model. Thus, there is no reason to smooth the loads, but we do need to make the solver aware of the times at which the changes in load occur. This is done via the Events interface. To add this interface, rightclick on the Component branch, and go to: Mathematics > ODE and DAE Interfaces > Events.
The Events interface allows you to include both Explicit Events and Implicit Events. When these events are triggered, the timedependent solver will stop and restart. By default it will consistently initialize all variables based upon the previous solution and new loads. You can, optionally, reinitialize some (or all) variables if you want them to change abruptly.
The Explicit Event feature should be used when you know the specific times at which a load may change. You can also specify a Period of event if you know that that change in loading will be repeating regularly in time, as shown in the screenshot below.
The Explicit Event interface
The Implicit Event on the other hand, can be used when a change in load occurs implicitly due to a condition that can occur at some unknown time, such as for thermostatic control. It must be combined with an Indicator States feature, that defines an Indicator Variable. The indicator state variables are used to trigger implicit events when the indicator state variable crosses zero, and when the implicit event condition changes from false to true. For example, in the screenshots below, and indicator variable Condition is defined as the average temperature minus 100°C. An Average Component Coupling named Average is used to take the average temperature over some domains. The implicit event is then triggered when the logical condition: Condition>0 goes from false to true.
The Indicator State interface
The Implicit Event interface
The accuracy of the solution for these types of models will be governed by the mesh size and the time dependent solver tolerances. You should perform mesh refinement studies and study tighter solver tolerances until the solution converges.
See also:
Knowledge Base 1240: Manually Setting the Scaling of Variables
Knowledge Base 1127: Improving convergence in nonlinear time dependent models
Implementing a Thermostat with the Events Interface
Disclaimer
COMSOL makes every reasonable effort to verify the information you view on this page. Resources and documents are provided for your information only, and COMSOL makes no explicit or implied claims to their validity. COMSOL does not assume any legal liability for the accuracy of the data disclosed. Any trademarks referenced in this document are the property of their respective owners. Consult your product manuals for complete trademark details.