SCRIPTWITHONEFUNCTION_FILE = SIMP(statut = "o", typ = "FichierNoAbs", validators=(OnlyStr()), fr="En attente d'un nom de fichier script, avec ou sans le chemin complet pour le trouver, contenant en variable interne une seule fonction de calcul nommée DirectOperator", ang="Waiting for a script file name, with or without the full path to find it, containing as internal variable only one function named DirectOperator"),
DifferentialIncrement = SIMP(statut="o", typ = "R", val_min=0, val_max=1, defaut=0.01, fr="Incrément de la perturbation dX pour calculer la dérivée, construite en multipliant X par l'incrément en évitant les valeurs nulles", ang="Increment of dX perturbation to calculate the derivative, build multiplying X by the increment avoiding null values"),
+ CenteredFiniteDifference = SIMP(statut="o", typ = "I", into=(0, 1), defaut=0, fr="Formulation centrée (1) ou décentrée (0) pour la méthode des différences finies", ang="Centered (1) or uncentered (0) formulation for the finite difference method"),
),
SCRIPTWITHSWITCH_DATA = BLOC ( condition = " FROM in ( 'ScriptWithSwitch', ) ",
First functional form: using "*ScriptWithOneFunction*"
++++++++++++++++++++++++++++++++++++++++++++++++++++++
+.. index:: single: ScriptWithOneFunction
+.. index:: single: DirectOperator
+.. index:: single: DifferentialIncrement
+.. index:: single: CenteredFiniteDifference
+
The first one consist in providing only one potentially non-linear function, and
to approximate the tangent and the adjoint operators. This is done by using the
keyword "*ScriptWithOneFunction*" for the description of the chosen operator in
In this case, the user can also provide a value for the differential increment,
using through the GUI the keyword "*DifferentialIncrement*", which has a default
value of 1%. This coefficient will be used in the finite difference
-approximation to build the tangent and adjoint operators.
+approximation to build the tangent and adjoint operators. The finite difference
+approximation order can also be chosen through the GUI, using the keyword
+"*CenteredFiniteDifference*", with 0 for an uncentered schema of first order,
+and with 1 for a centered schema of second order (of twice the first order
+computational cost). The keyword has a default value of 0.
This first operator definition allow easily to test the functional form before
its use in an ADAO case, greatly reducing the complexity of implementation.
Second functional form: using "*ScriptWithFunctions*"
+++++++++++++++++++++++++++++++++++++++++++++++++++++
+.. index:: single: ScriptWithFunctions
+.. index:: single: DirectOperator
+.. index:: single: TangentOperator
+.. index:: single: AdjointOperator
+
The second one consist in providing directly the three associated operators
:math:`O`, :math:`\mathbf{O}` and :math:`\mathbf{O}^*`. This is done by using
the keyword "*ScriptWithFunctions*" for the description of the chosen operator
Third functional form: using "*ScriptWithSwitch*"
+++++++++++++++++++++++++++++++++++++++++++++++++
+.. index:: single: ScriptWithSwitch
+.. index:: single: DirectOperator
+.. index:: single: TangentOperator
+.. index:: single: AdjointOperator
+
This third form give more possibilities to control the execution of the three
functions representing the operator, allowing advanced usage and control over
each execution of the simulation code. This is done by using the keyword
c'est-à-dire le gradient de H en X. On utilise des différences finies
directionnelles autour du point X. X est un numpy.matrix.
- Différences finies centrées :
+ Différences finies centrées (approximation d'ordre 2):
1/ Pour chaque composante i de X, on ajoute et on enlève la perturbation
dX[i] à la composante X[i], pour composer X_plus_dXi et X_moins_dXi, et
on calcule les réponses HX_plus_dXi = H( X_plus_dXi ) et HX_moins_dXi =
le pas 2*dXi
3/ Chaque résultat, par composante, devient une colonne de la Jacobienne
- Différences finies non centrées :
+ Différences finies non centrées (approximation d'ordre 1):
1/ Pour chaque composante i de X, on ajoute la perturbation dX[i] à la
composante X[i] pour composer X_plus_dXi, et on calcule la réponse
HX_plus_dXi = H( X_plus_dXi )
self.text_da += data_name + "_ScriptWithOneFunction['Script']['Tangent'] = '" + data + "'\n"
self.text_da += data_name + "_ScriptWithOneFunction['Script']['Adjoint'] = '" + data + "'\n"
self.text_da += data_name + "_ScriptWithOneFunction['DifferentialIncrement'] = " + str(float(self.dictMCVal[search_type + "SCRIPTWITHONEFUNCTION_DATA__DifferentialIncrement"])) + "\n"
+ self.text_da += data_name + "_ScriptWithOneFunction['CenteredFiniteDifference'] = " + str(self.dictMCVal[search_type + "SCRIPTWITHONEFUNCTION_DATA__CenteredFiniteDifference"]) + "\n"
self.text_da += data_name + "_config = {}\n"
self.text_da += data_name + "_config['Type'] = 'Function'\n"
self.text_da += data_name + "_config['From'] = 'ScriptWithOneFunction'\n"
node_script += """ raise ValueError("ComputationFunctionNode: DirectOperator not found in the imported user script file")\n"""
node_script += """import ApproximatedDerivatives\n"""
node_script += """FDA = ApproximatedDerivatives.FDApproximation(\n"""
- node_script += """ Function = DirectOperator,\n"""
- node_script += """ increment = %s,\n"""%str(ScriptWithOneFunction['DifferentialIncrement'])
+ node_script += """ Function = DirectOperator,\n"""
+ node_script += """ increment = %s,\n"""%str(ScriptWithOneFunction['DifferentialIncrement'])
+ node_script += """ centeredDF = %s,\n"""%str(ScriptWithOneFunction['CenteredFiniteDifference'])
node_script += """ )\n"""
node_script += """#\n"""
node_script += """__data = []\n"""
node_script += """ raise ValueError("ComputationFunctionNode: DirectOperator not found in the imported user script file")\n"""
node_script += """import ApproximatedDerivatives\n"""
node_script += """FDA = ApproximatedDerivatives.FDApproximation(\n"""
- node_script += """ Function = DirectOperator,\n"""
- node_script += """ increment = %s,\n"""%str(ScriptWithOneFunction['DifferentialIncrement'])
+ node_script += """ Function = DirectOperator,\n"""
+ node_script += """ increment = %s,\n"""%str(ScriptWithOneFunction['DifferentialIncrement'])
+ node_script += """ centeredDF = %s,\n"""%str(ScriptWithOneFunction['CenteredFiniteDifference'])
node_script += """ )\n"""
node_script += """#\n"""
node_script += """__data = []\n"""