{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"tags": [
"remove-input",
"active-ipynb",
"remove-output"
]
},
"outputs": [],
"source": [
"try:\n",
" from openmdao.utils.notebook_utils import notebook_mode\n",
"except ImportError:\n",
" !python -m pip install openmdao[notebooks]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Determining How Many Times a System was Executed\n",
"\n",
"All OpenMDAO `Systems` have a set of local counters that keep track of how many times they have\n",
"been executed.\n",
"\n",
"**iter_count**\n",
"\n",
" Counts the number of times this system has called _solve_nonlinear. This also\n",
" corresponds to the number of times that the system's outputs are recorded if a recorder\n",
" is present.\n",
"\n",
"**iter_count_apply**\n",
"\n",
" Counts the number of times the system has called _apply_nonlinear. For ExplicitComponent,\n",
" calls to apply_nonlinear also call compute, so number of executions can be found by adding\n",
" this and iter_count together. Recorders do no record calls to _apply_nonlinear.\n",
"\n",
"**iter_count_without_approx**\n",
"\n",
" Counts the number of times the system has iterated but excludes any that occur during\n",
" approximation of derivatives.\n",
"\n",
"When you have an `ExplicitComponent`, the number stored in iter_count may not match the total\n",
"number of times that the \"compute\" function has been called. This is because compute is also\n",
"called whenever '_apply_nonlinear' is called to compute the norm of the current residual. For\n",
"an explicit equation, the residual is defined as the difference in the value of the outputs\n",
"before and after execution, and an additional execution is required to compute this.\n",
"\n",
"The correct execution count for an ExplicitComponent can always be obtained by adding iter_count\n",
"and iter_count_apply.\n",
"\n",
"The recorder iteration coordinate will always match the iter_count because calls to apply_nonlinear\n",
"are not recorded.\n"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.1"
}
},
"nbformat": 4,
"nbformat_minor": 4
}