From c40698654ee28e8ab236c60228d665d64eab12b6 Mon Sep 17 00:00:00 2001
From: "mathias.chouet" <mathias.chouet@irstea.fr>
Date: Thu, 12 Sep 2019 11:28:16 +0200
Subject: [PATCH] Fix #286 - tie precision & maxIterations to model

get rid of Pr parameter
save displayPrecision in session files
---
 package-lock.json                             | 22 +--------
 src/app/app.component.ts                      | 12 ++++-
 .../cond_distri/cond_distri.en.json           |  3 +-
 .../lechapt-calmon/lechapt-calmon.en.json     |  3 +-
 .../lechapt-calmon/lechapt-calmon.fr.json     |  3 +-
 src/app/calculators/remous/remous.config.json |  1 -
 src/app/calculators/remous/remous.en.json     |  1 -
 src/app/calculators/remous/remous.fr.json     |  1 -
 .../section-param/section-param.en.json       |  1 -
 .../section-param/section-param.fr.json       |  1 -
 .../app-setup/app-setup.component.ts          |  4 +-
 .../dialog-generate-pab.component.ts          |  2 +-
 .../fixedvar-results/results.component.ts     |  2 +-
 .../log-entry/log-entry.component.ts          |  2 +-
 ...rorugo-compound-results-table.component.ts |  2 +-
 .../macrorugo-compound-results.component.ts   |  2 +-
 .../pab-table/pab-table.component.ts          |  4 +-
 src/app/config.json                           |  4 +-
 .../form-compute-section-parametree.ts        |  2 +-
 .../definition/form-result-fixedvar.ts        |  4 +-
 .../definition/form-result-section.ts         |  6 +--
 src/app/services/app-setup.service.ts         | 47 +++++++++++++------
 src/app/services/formulaire.service.ts        | 14 ++++++
 src/app/util.ts                               |  2 +-
 24 files changed, 79 insertions(+), 66 deletions(-)

diff --git a/package-lock.json b/package-lock.json
index 680c0999c..11ea8836e 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,6 +1,6 @@
 {
   "name": "fr.irstea.cassiopee",
-  "version": "4.4.2",
+  "version": "4.5.0",
   "lockfileVersion": 1,
   "requires": true,
   "dependencies": {
@@ -823,7 +823,6 @@
       "version": "7.5.5",
       "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.5.5.tgz",
       "integrity": "sha512-27d4lZoomVyo51VegxI20xZPuSHusqbQag/ztrBC7wegWoQ1nLREPVSKSW8byhTlzTKyNE4ifaTA6lCp7JjpFw==",
-      "dev": true,
       "requires": {
         "@babel/highlight": "^7.0.0"
       }
@@ -1123,7 +1122,6 @@
       "version": "7.5.0",
       "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.5.0.tgz",
       "integrity": "sha512-7dV4eu9gBxoM0dAnj/BCFDW9LFU0zvTrkq0ugM7pnHEgguOEeOz1so2ZghEdzviYzQEED0r4EAgpsBChKy1TRQ==",
-      "dev": true,
       "requires": {
         "chalk": "^2.0.0",
         "esutils": "^2.0.2",
@@ -7277,8 +7275,7 @@
     "electron-to-chromium": {
       "version": "1.3.252",
       "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.252.tgz",
-      "integrity": "sha512-NWJ5TztDnjExFISZHFwpoJjMbLUifsNBnx7u2JI0gCw6SbKyQYYWWtBHasO/jPtHym69F4EZuTpRNGN11MT/jg==",
-      "dev": true
+      "integrity": "sha512-NWJ5TztDnjExFISZHFwpoJjMbLUifsNBnx7u2JI0gCw6SbKyQYYWWtBHasO/jPtHym69F4EZuTpRNGN11MT/jg=="
     },
     "elementtree": {
       "version": "0.1.7",
@@ -12297,7 +12294,6 @@
       "version": "1.1.29",
       "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-1.1.29.tgz",
       "integrity": "sha512-R5bDhzh6I+tpi/9i2hrrvGJ3yKPYzlVOORDkXhnZuwi5D3q1I5w4vYy24PJXTcLk9Q0kws9TO77T75bcK8/ysQ==",
-      "dev": true,
       "requires": {
         "semver": "^5.3.0"
       }
@@ -12768,7 +12764,6 @@
       "version": "2.2.1",
       "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.2.1.tgz",
       "integrity": "sha512-85Tk+90UCVWvbDavCLKPOLC9vvY8OwEX/RtKF+/1OADJMVlFfEHOiMTPVyxg7mk/dKa+ipdHm0OUkTvCpMTuwg==",
-      "dev": true,
       "requires": {
         "p-try": "^2.0.0"
       }
@@ -12993,15 +12988,6 @@
         "safe-buffer": "^5.1.1"
       }
     },
-    "parse-color": {
-      "version": "1.0.0",
-      "resolved": "https://registry.npmjs.org/parse-color/-/parse-color-1.0.0.tgz",
-      "integrity": "sha1-e3SLlag/A/FqlPU15S1/PZRlhhk=",
-      "dev": true,
-      "requires": {
-        "color-convert": "~0.5.0"
-      }
-    },
     "parse-entities": {
       "version": "1.2.2",
       "resolved": "https://registry.npmjs.org/parse-entities/-/parse-entities-1.2.2.tgz",
@@ -16155,7 +16141,6 @@
       "version": "4.2.1",
       "resolved": "https://registry.npmjs.org/terser/-/terser-4.2.1.tgz",
       "integrity": "sha512-cGbc5utAcX4a9+2GGVX4DsenG6v0x3glnDi5hx8816X1McEAwPlPgRtXPJzSBsbpILxZ8MQMT0KvArLuE0HP5A==",
-      "dev": true,
       "requires": {
         "commander": "^2.20.0",
         "source-map": "~0.6.1",
@@ -16171,7 +16156,6 @@
           "version": "0.5.13",
           "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.13.tgz",
           "integrity": "sha512-SHSKFHadjVA5oR4PPqhtAVdcBWwRYVd6g6cAXnIbRiIwc2EhPrTuKUBdSLvlEKyIP3GCf89fltvcZiP9MMFA1w==",
-          "dev": true,
           "requires": {
             "buffer-from": "^1.0.0",
             "source-map": "^0.6.0"
@@ -17835,7 +17819,6 @@
           "version": "1.0.0",
           "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz",
           "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=",
-          "dev": true,
           "requires": {
             "number-is-nan": "^1.0.0"
           }
@@ -17844,7 +17827,6 @@
           "version": "1.0.2",
           "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz",
           "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=",
-          "dev": true,
           "requires": {
             "code-point-at": "^1.0.0",
             "is-fullwidth-code-point": "^1.0.0",
diff --git a/src/app/app.component.ts b/src/app/app.component.ts
index 98705daca..06a76e4af 100644
--- a/src/app/app.component.ts
+++ b/src/app/app.component.ts
@@ -389,6 +389,11 @@ export class AppComponent implements OnInit, OnDestroy, Observer {
     this.formulaireService.downloadTextFile(session, filename);
   }
 
+  /**
+   * Builds a session file including Nubs, GUI-specific Nubs metadata,
+   * model settings, GUI settings
+   * @param calcList Nubs to save
+   */
   private buildSessionFile(calcList: any[]): string {
     const serialiseOptions: { [key: string]: {} } = {};
     for (const c of calcList) {
@@ -398,7 +403,12 @@ export class AppComponent implements OnInit, OnDestroy, Observer {
         };
       }
     }
-    return Session.getInstance().serialise(serialiseOptions);
+    const settings = {
+      precision: this.appSetupService.computePrecision,
+      maxIterations: this.appSetupService.maxIterations,
+      displayPrecision: this.appSetupService.displayPrecision,
+    };
+    return Session.getInstance().serialise(serialiseOptions, settings);
   }
 
   /**
diff --git a/src/app/calculators/cond_distri/cond_distri.en.json b/src/app/calculators/cond_distri/cond_distri.en.json
index 372fff647..8afedf6b7 100644
--- a/src/app/calculators/cond_distri/cond_distri.en.json
+++ b/src/app/calculators/cond_distri/cond_distri.en.json
@@ -5,6 +5,5 @@
     "J": "Head drop",
     "Lg": "Pipe length",
     "Nu": "Dynamic (shear) viscosity",
-    "fs_param_calc": "Calculation parameters",
-    "Pr": "Display accuracy"
+    "fs_param_calc": "Calculation parameters"
 }
\ No newline at end of file
diff --git a/src/app/calculators/lechapt-calmon/lechapt-calmon.en.json b/src/app/calculators/lechapt-calmon/lechapt-calmon.en.json
index 8a22b96b9..1d9ee6024 100644
--- a/src/app/calculators/lechapt-calmon/lechapt-calmon.en.json
+++ b/src/app/calculators/lechapt-calmon/lechapt-calmon.en.json
@@ -19,6 +19,5 @@
     "D": "Pipe diameter",
     "J": "Head drop",
     "Lg": "Pipe length",
-    "fs_param_calc": "Calculation parameters",
-    "Pr": "Display accuracy"
+    "fs_param_calc": "Calculation parameters"
 }
\ No newline at end of file
diff --git a/src/app/calculators/lechapt-calmon/lechapt-calmon.fr.json b/src/app/calculators/lechapt-calmon/lechapt-calmon.fr.json
index 4455f5680..dbdb0e4dc 100644
--- a/src/app/calculators/lechapt-calmon/lechapt-calmon.fr.json
+++ b/src/app/calculators/lechapt-calmon/lechapt-calmon.fr.json
@@ -18,6 +18,5 @@
     "D": "Diamètre du tuyau",
     "J": "Perte de charge",
     "Lg": "Longueur du tuyau",
-    "fs_param_calc": "Paramètres de calcul",
-    "Pr": "Précision de calcul"
+    "fs_param_calc": "Paramètres de calcul"
 }
\ No newline at end of file
diff --git a/src/app/calculators/remous/remous.config.json b/src/app/calculators/remous/remous.config.json
index a6110791b..7651d9491 100644
--- a/src/app/calculators/remous/remous.config.json
+++ b/src/app/calculators/remous/remous.config.json
@@ -39,7 +39,6 @@
         "type": "fieldset",
         "fields": [
             "Dx",
-            "Pr",
             {
                 "id": "select_resolution",
                 "type": "select",
diff --git a/src/app/calculators/remous/remous.en.json b/src/app/calculators/remous/remous.en.json
index 15b6decab..8218e8109 100644
--- a/src/app/calculators/remous/remous.en.json
+++ b/src/app/calculators/remous/remous.en.json
@@ -23,7 +23,6 @@
     "Yamont": "Water level imposed at upstream",
     "fs_param_calc": "Calculation parameters",
     "Dx": "Discretisation step",
-    "Pr": "Display accuracy",
     "select_resolution": "Resolution method",
 
     "select_resolution_Trapezes": "Integration by trapezoid",
diff --git a/src/app/calculators/remous/remous.fr.json b/src/app/calculators/remous/remous.fr.json
index 25110976b..f38893d02 100644
--- a/src/app/calculators/remous/remous.fr.json
+++ b/src/app/calculators/remous/remous.fr.json
@@ -22,7 +22,6 @@
     "Yaval": "Tirant d'eau imposé à l'aval",
     "Yamont": "Tirant d'eau imposé à l'amont",
     "Dx": "Pas de discrétisation",
-    "Pr": "Précision de calcul des cotes",
     "select_resolution": "Méthode de résolution",
 
     "select_resolution_Trapezes": "Intégration par trapèzes",
diff --git a/src/app/calculators/section-param/section-param.en.json b/src/app/calculators/section-param/section-param.en.json
index 239f8e0f5..da77bfab8 100644
--- a/src/app/calculators/section-param/section-param.en.json
+++ b/src/app/calculators/section-param/section-param.en.json
@@ -20,7 +20,6 @@
     "Q": "Flow",
     "Y": "Draft",
     "fs_param_calc": "Calculation parameters",
-    "Pr": "Display accuracy",
     "Hs": "Charge spécifique",
     "Hsc": "Charge critique",
     "B": "Largeur au miroir",
diff --git a/src/app/calculators/section-param/section-param.fr.json b/src/app/calculators/section-param/section-param.fr.json
index 07532c3de..0de692fe9 100644
--- a/src/app/calculators/section-param/section-param.fr.json
+++ b/src/app/calculators/section-param/section-param.fr.json
@@ -19,7 +19,6 @@
     "fs_hydraulique": "Caractéristiques hydrauliques",
     "Y": "Tirant d'eau",
     "fs_param_calc": "Paramètres de calcul",
-    "Pr": "Précision de calcul",
     "Hs": "Charge spécifique",
     "Hsc": "Charge critique",
     "B": "Largeur au miroir",
diff --git a/src/app/components/app-setup/app-setup.component.ts b/src/app/components/app-setup/app-setup.component.ts
index bb7823674..95123bc93 100644
--- a/src/app/components/app-setup/app-setup.component.ts
+++ b/src/app/components/app-setup/app-setup.component.ts
@@ -134,7 +134,7 @@ export class ApplicationSetupComponent implements Observer, OnInit {
         this.computePrec.addObserver(this);
 
         // modèle du composant BaseParamInputComponent du max d'itérations pour Newton
-        this.newtonMaxIter = new NgBaseParam("nmi", ParamDomainValue.POS, this.appSetupService.newtonMaxIterations);
+        this.newtonMaxIter = new NgBaseParam("nmi", ParamDomainValue.POS, this.appSetupService.maxIterations);
         this.newtonMaxIter.addObserver(this);
 
         // notifications
@@ -160,7 +160,7 @@ export class ApplicationSetupComponent implements Observer, OnInit {
                     break;
 
                 case "nmi":
-                    this.appSetupService.newtonMaxIterations = +data;
+                    this.appSetupService.maxIterations = +data;
                     break;
             }
         }
diff --git a/src/app/components/dialog-generate-pab/dialog-generate-pab.component.ts b/src/app/components/dialog-generate-pab/dialog-generate-pab.component.ts
index 07943130e..e53e7fd5d 100644
--- a/src/app/components/dialog-generate-pab/dialog-generate-pab.component.ts
+++ b/src/app/components/dialog-generate-pab/dialog-generate-pab.component.ts
@@ -28,7 +28,7 @@ export class DialogGeneratePABComponent {
     private appSetupService: ApplicationSetupService,
     @Inject(MAT_DIALOG_DATA) public data: any
   ) {
-    const nDigits = this.appSetupService.displayDigits;
+    const nDigits = this.appSetupService.displayPrecision;
     this.coteAmont = round(data.coteAmont, nDigits);
     this.debit = round(data.debit, nDigits);
     this.chute = round(data.chute, nDigits);
diff --git a/src/app/components/fixedvar-results/results.component.ts b/src/app/components/fixedvar-results/results.component.ts
index 1fae7bd06..d5282b1b1 100644
--- a/src/app/components/fixedvar-results/results.component.ts
+++ b/src/app/components/fixedvar-results/results.component.ts
@@ -88,7 +88,7 @@ export class ResultsComponent {
         } else if (typeof p === "number") {
             originalValue = p;
         }
-        const nDigits = ServiceFactory.instance.applicationSetupService.displayDigits;
+        const nDigits = ServiceFactory.instance.applicationSetupService.displayPrecision;
         const minRenderableNumber = Number("1E-" + nDigits);
         // if required precision is too low, avoid rendering only zeroes
         if (originalValue < minRenderableNumber) {
diff --git a/src/app/components/log-entry/log-entry.component.ts b/src/app/components/log-entry/log-entry.component.ts
index 923c0c195..5cdb305db 100644
--- a/src/app/components/log-entry/log-entry.component.ts
+++ b/src/app/components/log-entry/log-entry.component.ts
@@ -35,7 +35,7 @@ export class LogEntryComponent implements OnChanges {
     }
 
     private updateText() {
-        const nDigits = this.appSetupService.displayDigits;
+        const nDigits = this.appSetupService.displayPrecision;
         this._text = this.intlService.localizeMessage(this._message, nDigits);
     }
 
diff --git a/src/app/components/macrorugo-compound-results/macrorugo-compound-results-table.component.ts b/src/app/components/macrorugo-compound-results/macrorugo-compound-results-table.component.ts
index def97e912..47158dc9a 100644
--- a/src/app/components/macrorugo-compound-results/macrorugo-compound-results-table.component.ts
+++ b/src/app/components/macrorugo-compound-results/macrorugo-compound-results-table.component.ts
@@ -48,7 +48,7 @@ export class MacrorugoCompoundResultsTableComponent extends ResultsComponent {
             && ! this._mrcResults.hasOnlyErrors()
         ) {
             const pr = this._mrcResults;
-            const nDigits = this.appSetupService.displayDigits;
+            const nDigits = this.appSetupService.displayPrecision;
             // when a parameter is variating, index of the variating parameter
             // values to build the data from
             const vi = pr.variableIndex;
diff --git a/src/app/components/macrorugo-compound-results/macrorugo-compound-results.component.ts b/src/app/components/macrorugo-compound-results/macrorugo-compound-results.component.ts
index a97668c9b..042da7ba5 100644
--- a/src/app/components/macrorugo-compound-results/macrorugo-compound-results.component.ts
+++ b/src/app/components/macrorugo-compound-results/macrorugo-compound-results.component.ts
@@ -283,7 +283,7 @@ export class MacrorugoCompoundResultsComponent implements DoCheck {
     }
 
     public formattedValue(p: NgParameter): string {
-        const nDigits = this.appSetupService.displayDigits;
+        const nDigits = this.appSetupService.displayPrecision;
         return p.getValue().toFixed(nDigits);
     }
 
diff --git a/src/app/components/pab-table/pab-table.component.ts b/src/app/components/pab-table/pab-table.component.ts
index 3bff2bb05..f867c9c20 100644
--- a/src/app/components/pab-table/pab-table.component.ts
+++ b/src/app/components/pab-table/pab-table.component.ts
@@ -437,7 +437,7 @@ export class PabTableComponent implements AfterViewInit, OnInit {
         const maxNbDevices = this.findMaxNumberOfDevices();
 
         // adjuste precision once before anything else
-        const nDigits = this.appSetupService.displayDigits;
+        const nDigits = this.appSetupService.displayPrecision;
         for (const c of this.model.children) {
             for (const p of c.parameterIterator) {
                 if (p.visible) {
@@ -1304,7 +1304,7 @@ export class PabTableComponent implements AfterViewInit, OnInit {
 
                         case "interpolate":
                             if (result.variableDetails.occurrences > 1) {
-                                const nDigits = this.appSetupService.displayDigits;
+                                const nDigits = this.appSetupService.displayPrecision;
                                 const interpolatedValues: number[] = [];
                                 const variableRange = result.variableDetails.last - result.variableDetails.first;
                                 let totalBasinsLengths = 0;
diff --git a/src/app/config.json b/src/app/config.json
index a494eee07..c2ec2a974 100644
--- a/src/app/config.json
+++ b/src/app/config.json
@@ -1,8 +1,8 @@
 {
     "params": {
         "displayPrecision": 3,
-        "computePrecision": 0.0001,
-        "newtonMaxIterations": 50,
+        "computePrecision": 0.0000001,
+        "maxIterations": 100,
         "enableNotifications": true,
         "enableHotkeys": false,
         "language": "fr"
diff --git a/src/app/formulaire/definition/form-compute-section-parametree.ts b/src/app/formulaire/definition/form-compute-section-parametree.ts
index a1380b658..0a47bd11f 100644
--- a/src/app/formulaire/definition/form-compute-section-parametree.ts
+++ b/src/app/formulaire/definition/form-compute-section-parametree.ts
@@ -49,7 +49,7 @@ export class FormComputeSectionParametree extends FormCompute {
             // résultats de section (avec le graphique de section)
             this._sectionResults.result = sectNub.result;
             // résultats complémentaires des paramètres fixés
-            this._formSectionResult.addSectionFixedParameters(false);
+            this._formSectionResult.addSectionFixedParameters();
             this._formSectionResult.fixedResults.result = sectNub.result;
         }
 
diff --git a/src/app/formulaire/definition/form-result-fixedvar.ts b/src/app/formulaire/definition/form-result-fixedvar.ts
index 6a79f021e..dbc56f6c2 100644
--- a/src/app/formulaire/definition/form-result-fixedvar.ts
+++ b/src/app/formulaire/definition/form-result-fixedvar.ts
@@ -37,9 +37,7 @@ export class FormResultFixedVar extends FormResult {
 
     public addFixedParameters() {
         for (const p of this._formBase.getDisplayedParamListFromState(ParamRadioConfig.FIX)) {
-            if (p.symbol !== "Pr") {
-                this._fixedResults.addFixedParameter(p);
-            }
+            this._fixedResults.addFixedParameter(p);
         }
 
         for (const p of this._formBase.getDisplayedParamListFromState(ParamRadioConfig.LINK)) {
diff --git a/src/app/formulaire/definition/form-result-section.ts b/src/app/formulaire/definition/form-result-section.ts
index 836a95edf..73d5f0e87 100644
--- a/src/app/formulaire/definition/form-result-section.ts
+++ b/src/app/formulaire/definition/form-result-section.ts
@@ -46,11 +46,9 @@ export class FormResultSection extends FormResult {
         this._sectionResults.reset();
     }
 
-    public addSectionFixedParameters(displaySymbol: boolean) {
+    public addSectionFixedParameters() {
         for (const p of this._formBase.getDisplayedParamListFromState(ParamRadioConfig.FIX)) {
-            if (p.symbol !== "Pr") {
-                this._fixedResults.addFixedParameter(p);
-            }
+            this._fixedResults.addFixedParameter(p);
         }
     }
 
diff --git a/src/app/services/app-setup.service.ts b/src/app/services/app-setup.service.ts
index e2c519d44..fe7a624da 100644
--- a/src/app/services/app-setup.service.ts
+++ b/src/app/services/app-setup.service.ts
@@ -1,6 +1,9 @@
-import { HttpService } from "./http.service";
 import { Injectable, Inject } from "@angular/core";
-import { Observable } from "jalhyd";
+
+import { HttpService } from "./http.service";
+
+import { Observable, SessionSettings } from "jalhyd";
+
 import { StorageService, LOCAL_STORAGE } from "ngx-webstorage-service";
 
 /**
@@ -17,11 +20,31 @@ export class ApplicationSetupService extends Observable {
 
     // default builtin values
     public displayPrecision = 3;
-    public computePrecision = 0.0001;
-    public newtonMaxIterations = 50;
+    private _computePrecision = 1e-7; // tied to model
+    private _maxIterations = 100; // tied to model
     public enableNotifications = true;
     public enableHotkeys = false;
 
+    public set computePrecision(p: number) {
+        this._computePrecision = p;
+        // forward to model
+        SessionSettings.precision = p;
+    }
+
+    public get computePrecision(): number {
+        return this._computePrecision;
+    }
+
+    public set maxIterations(m: number) {
+        this._maxIterations = m;
+        // forward to model
+        SessionSettings.maxIterations = m;
+    }
+
+    public get maxIterations(): number {
+        return this._maxIterations;
+    }
+
     /**
      * just stores the current language preference, does not transmit it to I18nService, that is
      * not available here.
@@ -70,10 +93,6 @@ export class ApplicationSetupService extends Observable {
         });
     }
 
-    public get displayDigits() {
-        return this.displayPrecision;
-    }
-
     public get fallbackLanguage() {
         return this._fallbackLanguage;
     }
@@ -84,7 +103,7 @@ export class ApplicationSetupService extends Observable {
     public saveValuesIntoLocalStorage() {
         this.storage.set(this.LOCAL_STORAGE_PREFIX + "displayPrecision", this.displayPrecision);
         this.storage.set(this.LOCAL_STORAGE_PREFIX + "computePrecision", this.computePrecision);
-        this.storage.set(this.LOCAL_STORAGE_PREFIX + "newtonMaxIterations", this.newtonMaxIterations);
+        this.storage.set(this.LOCAL_STORAGE_PREFIX + "maxIterations", this.maxIterations);
         this.storage.set(this.LOCAL_STORAGE_PREFIX + "enableNotifications", this.enableNotifications);
         this.storage.set(this.LOCAL_STORAGE_PREFIX + "enableHotkeys", this.enableHotkeys);
         this.storage.set(this.LOCAL_STORAGE_PREFIX + "language", this.language);
@@ -119,10 +138,10 @@ export class ApplicationSetupService extends Observable {
             this.computePrecision = computePrecision;
             loadedKeys.push("computePrecision");
         }
-        const newtonMaxIterations = this.storage.get(this.LOCAL_STORAGE_PREFIX + "newtonMaxIterations");
-        if (newtonMaxIterations !== undefined) {
-            this.newtonMaxIterations = newtonMaxIterations;
-            loadedKeys.push("newtonMaxIterations");
+        const maxIterations = this.storage.get(this.LOCAL_STORAGE_PREFIX + "maxIterations");
+        if (maxIterations !== undefined) {
+            this.maxIterations = maxIterations;
+            loadedKeys.push("maxIterations");
         }
         const enableNotifications = this.storage.get(this.LOCAL_STORAGE_PREFIX + "enableNotifications");
         if (enableNotifications !== undefined) {
@@ -150,7 +169,7 @@ export class ApplicationSetupService extends Observable {
             // get all config values (volontarily non-generic to prevent side-effects)
             this.displayPrecision = data.params.displayPrecision;
             this.computePrecision = data.params.computePrecision;
-            this.newtonMaxIterations = data.params.newtonMaxIterations;
+            this.maxIterations = data.params.maxIterations;
             this.enableNotifications = data.params.enableNotifications;
             this.enableHotkeys = data.params.enableHotkeys;
             this.language = data.params.language;
diff --git a/src/app/services/formulaire.service.ts b/src/app/services/formulaire.service.ts
index b331c4946..d880cb7d3 100644
--- a/src/app/services/formulaire.service.ts
+++ b/src/app/services/formulaire.service.ts
@@ -594,6 +594,20 @@ export class FormulaireService extends Observable {
                 await this.loadLocalisation(nn.nub.calcType);
                 await this.createFormulaire(nn.nub.calcType, nn.nub, title); // await guarantees loading order
             }
+            // apply settings
+            if (res.settings) {
+                // model based settings
+                if (res.settings.precision !== undefined) {
+                    this.appSetupService.computePrecision = res.settings.precision;
+                }
+                if (res.settings.maxIterations !== undefined) {
+                    this.appSetupService.maxIterations = res.settings.maxIterations;
+                }
+                // GUI settings
+                if (res.settings.displayPrecision !== undefined) {
+                    this.appSetupService.displayPrecision = res.settings.displayPrecision;
+                }
+            }
             // forward errors
             return {
                 hasErrors: res.hasErrors,
diff --git a/src/app/util.ts b/src/app/util.ts
index 9fe14833b..6d6a10bb1 100644
--- a/src/app/util.ts
+++ b/src/app/util.ts
@@ -26,7 +26,7 @@ export function fv(p: NgParameter | number): string {
     } else if (typeof p === "number") {
         value = p;
     }
-    const nDigits = ServiceFactory.instance.applicationSetupService.displayDigits;
+    const nDigits = ServiceFactory.instance.applicationSetupService.displayPrecision;
 
     return formattedValue(value, nDigits);
 }
-- 
GitLab