Click or drag to resize

Transfer Function Example

Below, an example implementation of a RelaxISPlugin_TransferFunction is shown.

The function of the plugin is chosen for illustrative purposes.

Requirements
  • Reference to the RelaxIS_SDK.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 the implementation of an Transfer Function plugin.

The plugin reimplements the complex capacitance and also includes the normalization to the permittivity.

Example
C#
// <copyright file="MyTransferFunction.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.Plugins
{
    using System;
    using RelaxIS_SDK.libMath;
    using RelaxIS_SDK.Plugins;

    /// <summary>
    /// Defines an example <see cref="RelaxISPlugin_TransferFunction"/> class.
    /// </summary>
    internal class MyTransferFunction
        : RelaxISPlugin_TransferFunction
    {
        /***
         * First, implement the default plugin properties Name and Description that describe the plugin.
         * This is mainly used for display purposes.
         */

        /// <inheritdoc/>
        public override string Name
        {
            get { return "My Transfer function"; }
        }

        /// <inheritdoc/>
        public override string Description
        {
            get { return "Reimplements the complex capacitance as an example."; }
        }

        /***
         * The symbol and unit propertier are typically used for display purposes, e.g. by AxisValue plugins
         * to define what is shown on a graph axis.
         */

        /// <inheritdoc/>
        public override string Symbol
        {
            get { return "C"; }
        }

        /// <inheritdoc/>
        public override string Unit
        {
            get { return "F"; }
        }

        /***
         * This property defines if for "regular" data the imaginary part is more likely negative than positive.
         * This is of course subjective. The intention is to allow PlotPreset plugins to better select between
         * the ImaginaryPart or NegativeImaginaryPart axis value plugins to show the plot more in the same quadrant of a plot.
         */

        /// <inheritdoc/>
        public override bool IsImaginaryUsuallyNegative
        {
            get { return true; }
        }

        /***
         * Each transfer function can define one way to be normalized with geometric data: area and thickness.
         * For the complex capacitance the most common corresponding value would be the complex permittivity,
         * where C = eps0 * eps * A / d or eps = C / eps0 * d / A.
         * The CanBeNormalized property signals to RelaxIS that a normalization is implemented and the normalized
         * Symbol and Unit properties define the display parameters when the normalized function is used.
         * If CanBeNormalized is true, the NormalizeValue function should be overridden and implemented.
         */

        /// <inheritdoc/>
        public override bool CanBeNormalized
        {
            get
            {
                return true;
            }
        }

        /// <inheritdoc/>
        public override string NormalizedSymbol
        {
            get
            {
                return "eps";
            }
        }

        /// <inheritdoc/>
        public override string NormalizedUnit
        {
            get
            {
                return string.Empty; // Permittivity is dimensionless
            }
        }

        /***
         * This function should recalculate the given impedance values into the target transfer function.
         */

        /// <inheritdoc/>
        public override Complex ConvertValue(double Frequency, double ZReal, double ZImag)
        {
            var w = Frequency * 2.0 * Math.PI;
            var iw = new Complex(0, w);
            var z = new Complex(ZReal, ZImag);

            // Complex capacitance is C = 1 / (i * w * Z)
            return 1.0 / (iw * z);
        }

        /***
         * Here we start out with the capacitance value and calculate the permittivity from it
         */

        /// <inheritdoc/>
        public override Complex NormalizeValue(double Frequency, double Real, double Imaginary, double Area, double Thickness)
        {
            var c = new Complex(Real, Imaginary);

            // eps = C / eps0 * d / A;
            var eps0 = 8.8541878e-12; // [F/m]
            return c / eps0 * Thickness / Area;
        }
    }
}
See Also