Keywords: DeveloppersGuide

## New ion correction

1) Create a new class which implements the CorrectionMethod interface or, if it is adapted, which extends the EntropyCorrection class in the melting.correctionMethods package.
The class must be created in the adapted package : melting.ionCorrection.magnesiumCorrection if it is a new magnesium correction, melting.ionCorrection.mixedNaMgCorrection if it is a new mixed monovalent correction, magnesium correction or melting.ionCorrection.sodiumCorrection if it is a new sodium correction.

If you just implement the CorrectionMethod interface, you have to implement the public methods boolean isApplicable(Environment environment) and ThermoResult correctMeltingResults(Environment environment) The first method is important to define the conditions of application of the ion correction and the second is important to correct the computed melting temperature.

The EntropyCorrection is a base implementation for ion corrections which directly correct the computed entropy and then compute te melting temperature. If you extend EntropyCorrection, you have to override the public method boolean isApplicable(Environment environment) to define the conditions of application of the ion correction.
The public method ThermoResult correctMeltingResults(Environment environment) is already implemented by EntropyCorrection but you have to override the method protected double correctEntropy(Environment environment) to correct the computed entropy.

2) Register the ion correction name and the class which represents it in the RegisterMethods class (melting.configuration package). You have to add into the function private void initialiseIonCorrectionMethod() of RegisterMethods this following line :

    private void initialiseIonCorrectionMethod(){
    		[...]

    		ionCorrection.put("sodiumCorrection-Name",
    		                               Class-Name.class);
    	}

3) Don't forget to add a private static String instance variable in your class. This String represents the correction formula you applied to the computed melting temperature or the computed entropy and must be printed if the verbose mode is required by the user.

    // Create a private static String which represents the
    // correction formula
    private static String correctionFormula = "formula";

    [...]

    // To print the article reference of the correction
    // formula if the verbose mode is required.
    OptionManagement.meltingLogger.log(Level.FINE, "article
                               reference of the correction");

    // To print the correction formula (the private static String)
    OptionManagement.meltingLogger.log(Level.FINE,
                                      correctionFormula);

    [...]
    }

4) In case of sodium corrections, you can use the method public static computesNaEquivalent(environment) of the Helper class in melting package to convert the sodium concentration entered by the user into a sodium equivalent concentration which takes into account the other cations entered by the user.

    double NaEq = Helper.computesNaEquivalent(environment);