Understanding NL Residuals in Simvascular History File and Setting Simulation Tolerance

Provides a system for patient-specific cardiovascular modeling and simulation.
POST REPLY
User avatar
flaminia stentella
Posts: 1
Joined: Tue Oct 24, 2023 3:39 am

Understanding NL Residuals in Simvascular History File and Setting Simulation Tolerance

Post by flaminia stentella » Mon Apr 29, 2024 2:23 am

Hello everyone,

I've been working with Simvascular and examining the history.dat file generated from a steady simulation using the SV solver. As documented, the third column of the table represents the NL residuals. However, I'm struggling to grasp what exactly these residuals refer to: are they considered rms residuals or max residuals? I think that the distinction is crucial as it affects the interpretation of their values.

Furthermore, I've noticed instances where there are two rows with the same time step number, with the second residual being smaller than the first. I believe this indicates convergence, but I'm puzzled as to why not all rows exhibit this behavior. Could this dual residual be a result of the two iterations I've set? If so, shouldn't all time steps have two residuals? Additionally, I've observed cases where the residuals in rows with only one residual are higher than those with two, suggesting that the solver hasn't settled for that value.

Another aspect I'm uncertain about is what these residuals specifically refer to. Are they a combination of residuals from continuity and momentum equations? Shouldn't there be at least one for the continuity equation and one for the momentum equations in the x, y, and z directions?

Lastly, I'm curious about how to set the tolerance for the simulation. Is there a method within Simvascular to define this tolerance, and if so, could someone please guide me through the process?

Your insights and guidance on these matters would be greatly appreciated. Thank you in advance for your assistance!

Best regards,
Flaminia

User avatar
David Parker
Posts: 1615
Joined: Tue Aug 23, 2005 2:43 pm

Re: Understanding NL Residuals in Simvascular History File and Setting Simulation Tolerance

Post by David Parker » Mon Apr 29, 2024 4:52 pm

Hi Flaminia,

One of the benefits of open source software is that you can examine the source code to get an idea about how the code works (see https://github.com/SimVascular/svSolver). When asked a detailed implementation question I too will need to look at the source.

I've been working with Simvascular and examining the history.dat file generated from a steady simulation using the SV solver. As documented, the third column of the table represents the NL residuals. However, I'm struggling to grasp what exactly these residuals refer to: are they considered rms residuals or max residuals? I think that the distinction is crucial as it affects the interpretation of their values.

At svSolver/Code/FlowSolvers/ThreeDSolver/svSolver/solver_subroutines.f line 14119 I see that the following variables are written to the histor.dat file

Code: Select all

             write (ihist,2000) lstep+1, cputme, totres, jtotrs,
     &          rmaxdyU, rmaxdyP, nrsmax,
     &          mproc(1)+1,jresmx,int(statsflow(4)),
     &          int(statsflow(1))
You can search the code to see how these variables are calculated. For example in svSolver/Code/FlowSolvers/ThreeDSolver/svSolver/solver_subroutines.f line 14078 I see

Code: Select all

        totres = resnrm / float(nshgt)   
        totres = sqrt(totres)
        resmax = sqrt(resmax)
        if (resfrt .eq. zero) resfrt = totres
        jtotrs = int  ( 10.d0 * log10 ( totres / resfrt ) )
        jresmx = int  ( 10.d0 * log10 ( resmax / totres ) )
Furthermore, I've noticed instances where there are two rows with the same time step number, with the second residual being smaller than the first. I believe this indicates convergence, but I'm puzzled as to why not all rows exhibit this behavior. Could this dual residual be a result of the two iterations I've set? If so, shouldn't all time steps have two residuals? Additionally, I've observed cases where the residuals in rows with only one residual are higher than those with two, suggesting that the solver hasn't settled for that value.

There are two rows because the solver is using two two non-linear iterations, I think this is set using the STEP CONSTRUCTION BLOCK parameter. I suppose if the residual is small enough then only a single iteration is performed.

Lastly, I'm curious about how to set the tolerance for the simulation. Is there a method within Simvascular to define this tolerance, and if so, could someone please guide me through the process?

There are several tolerances that you can set from the GUi

Code: Select all

Tolerance on Momentum Equations: 0.05                   
Tolerance on Continuity Equations: 0.4                 
Tolerance on svLS NS Solver: 0.4                             
The Residual Tolerance can only be set by editing the solver.inp file.

Cheers,
Dave

POST REPLY