Click or drag to resize

WCF Link - Analysis Functions

The code below shows some examples of using further analysis functions exposed by the IRelaxISWCFLink WCF interface.

The functions generally first construct a RelaxISWCFLinkProxy object by calling GetDefaultProxy. This proxy object is then used to call the functions. This will then execute the functions in the RelaxIS instance that has an active WCF Link.

Requirements
  • Reference to the RelaxIS_SDK.dll

  • Reference to System.ServiceModel.dll

  • .NET Framework 4.7.2 target (class library)

  • Recommended: Development environment with compiler e.g. RelaxIS SDK Code Editor, Microsoft Visual Studio

Demonstrates

This examples illustrates how to get the results of a DRT and a Kramers-Kronig analysis for an impedance spectrum.

The spectrum data is generated by a GetExampleData() function that outputs spectrum data as an IListEISDatapoint.

The example then define settings objects for the respective analysis function and then gets the result via the WCF Link.

The results are written to the console.

Example
C#
// <copyright file="WCFFurtherAnalysis.cs" company="rhd instruments GmbH and Co. KG">
// Copyright (c) rhd instruments GmbH and Co. KG. All rights reserved.
// Licensed under the MIT No Attribution (MIT-0) license. See section 'License' in the 'SDK Examples / Tutorials' topic for full license information.
// </copyright>

namespace RelaxIS_SDK_Examples.WCFInterface
{
    using System;
    using System.Linq;
    using RelaxIS_SDK.Common;
    using RelaxIS_SDK.RelaxISWCFLink;
    using RelaxIS_SDK.RelaxISWCFLink.DRT;
    using RelaxIS_SDK.RelaxISWCFLink.KramersKronig;

    /// <summary>
    /// Implements examples of further analysis functions such as DRT and Kramers-Kronig.
    /// </summary>
    public static class WCFFurtherAnalysis
    {
        /// <summary>
        /// Implements an example of performing a DRT analysis via the WCF Link.
        /// </summary>
        public static void PerformDRT()
        {
            // Get the interface object
            using (var wcf = RelaxISWCFLinkProxy.GetDefaultProxy())
            {
                // Create a spectrum that contains the data
                var spectrum = new ImpedanceSpectrum(CommonFunctions.GetExampleData());
                var settings = new DRTSettings()
                {
                    AutomaticNumberOfPoints = true,
                    DataType = DataType.Complex,
                    DerivativeType = DerivativeType.FirstOrder,
                    DiscretizationFunction = DiscretizationFunction.Gaussian,
                    DoInterpolate = false,
                    InterpolationCount = 0,
                    FitInductivity = true,
                    FrequencyExtrapolationFactor = 10,
                    Lambda = 0.1,
                    NumberOfPoints = 100,
                    PolarizationRemoval = PolarizationRemoval.DontRemove,
                    ShapeFactor = 0.5,
                };

                var drt = wcf.GetDRT(spectrum, settings);
                var reproduction = wcf.GetDRTReproduction(spectrum.Data.Select(d => d.Impedance.Frequency).ToList(), drt.Taus, drt.Gammas, drt.Resistance, drt.Inductivity);

                Console.WriteLine("DRT Result:");
                Console.WriteLine("Tau\tGamma");
                for (var i = 0; i < drt.Gammas.Count; i++)
                {
                    Console.WriteLine(string.Format("{0}\t{1}", drt.Taus[i], drt.Gammas[i]));
                }

                Console.WriteLine();
                Console.WriteLine("Reproduction:");
                Console.WriteLine("Frequency\tZ'\tZ''");
                for (var i = 0; i < reproduction[0].Length; i++)
                {
                    Console.WriteLine(string.Format("{0}\t{1}\t{2}", reproduction[0][i], reproduction[1][i], reproduction[2][i]));
                }
            }
        }

        /// <summary>
        /// Implements an example of performing a KK transformation via the WCF link.
        /// </summary>
        public static void KramersKronig()
        {
            // Get the interface object
            using (var wcf = RelaxISWCFLinkProxy.GetDefaultProxy())
            {
                // Create a spectrum that contains the data
                var spectrum = new ImpedanceSpectrum(CommonFunctions.GetExampleData());
                var settings = new KramersKronigSettings()
                {
                    Algorithm = KKAlgorithmType.Complex,
                    FitCapacitance = true,
                    FitInductivity = true,
                    NoTimeConstants = spectrum.Data.Count / 2,
                    UseAdmittance = false,
                };

                var kk = wcf.GetKramersKronigTransformation(spectrum, settings);
                Console.WriteLine("Kramers Kronig Result:");
                Console.WriteLine("Frequency\tZ'\tZ''");
                for (var i = 0; i < kk.ResultData.Count; i++)
                {
                    var p = kk.ResultData[i].Impedance;
                    Console.WriteLine(string.Format("{0}\t{1}\t{2}", p.Frequency, p.Real, p.Imaginary));
                }
            }
        }
    }
}
See Also

Reference

IRelaxISWCFLink

Other Resources

List of examples