Derivatives (Sensitivities)ΒΆ

Derivative information of the goal functional with respect to input parameters are useful for studying the sensitivity of the output quantity under small perturbations of the input parameters. Furthermore, the most performance optimization and higher order interpolation require the computation of functional derivatives.

To support this, JCMsuite allows for the automatic computation of the derivatives. Furthermore, by using derivative information parameter scans can be accelerated by an higher order interpolation method.

This example demonstrates the computation of derivatives of the transmitted Fourier coefficients with respect to the plane wave illumination parameters \lambda_0 and the direction angles \vartheta, \varphi, as well as with respect to the geometrical parameters (height and upper width of the structure).

To define the illumination derivatives, remind that the sources.jcm input file has the data-tree like form

SourceBag {
  Source {
  ElectricFieldStrength {
    PlaneWave {
      Lambda0 = ...
      ThetaPhi = [...]
    }
  }
}

You can identify each input value by its tree path. For example the parameter Lambda0 within the PlaneWave section has the path SourceBag/Source/PlaneWave/Lambda0.

To activate automatic differentiation we declare derivative parameters at the beginning of the sources.jcm input file:

DerivativeParameter {
  Name = "Lambda0"
  TreeEntry = SourceBag/Source/ElectricFieldStrength/PlaneWave/Lambda0
}

DerivativeParameter {
  Name = "Theta"
  TreeEntry = SourceBag/Source/ElectricFieldStrength/PlaneWave/ThetaPhi(1)
}

DerivativeParameter {
  Name = "Phi"
  TreeEntry = SourceBag/Source/ElectricFieldStrength/PlaneWave/ThetaPhi(2)
}

With a TreeEntry declaration we select a scalar input value for differentiation its tree path. The Name of the derivative parameters is used in the output files to refer to the specific derivative (see below for an usage within Matlab).

Similarly, the layout.jcm input file has the data-tree like form

Layout3D {
  ...
  Extrusion {
    ...

  MultiLayer {
    Layer
    {
      Name = "PatternLayer"
      Thickness = %(pattern_height)e
      ...
    }
    LayerInterface {
      Name = "PatternTopInterface"
      GeometryValues = [
        Pattern/Height = 190
        Pattern/Width = %(pattern_width_top)e
      ]
    }
    ...
  }
}

The structure height parameter has the tree path Layout3D/Extrusion/PatternLayer/Thickness (Here we used PatternLayer instead of the section tag Layer. This is allowed for named section with a Name attribute).

To activate automatic differentiation we declare derivative parameters at the beginning of the layout.jcm input file:

DerivativeParameter {
  Name = "PatternWidthTop"
  TreeEntry = Layout3D/Extrusion/MultiLayer/PatternTopInterface/GeometryValues/Pattern/Width
}

DerivativeParameter {
  Name = "PatternHeight"
  TreeEntry = Layout3D/Extrusion/MultiLayer/PatternLayer/Thickness
}

Within Matlab, the table of the transmitted Fourier coefficients now comes with following additional columns containing the derivatives with respect to the three parameters:

% primary Fourier coefficients of the two fields
ft_s = fourierTransform_transmitted.ElectricFieldStrength{1};
ft_p = fourierTransform_transmitted.ElectricFieldStrength{2};

% lambda0-derivatives of the Fourier coefficients of the two fields
dLambda0_ft_s =  fourierTransform_transmitted.d_Lambda0_ElectricFieldStrength{1};
dLambda0_ft_p =  fourierTransform_transmitted.d_Lambda0_ElectricFieldStrength{2};

% theta-derivatives of the Fourier coefficients of the two fields
dTheta_ft_s =  fourierTransform_transmitted.d_Theta_ElectricFieldStrength{1};
dTheta_ft_p =  fourierTransform_transmitted.d_Theta_ElectricFieldStrength{2};

% phi-derivatives of the Fourier coefficients of the two fields
dPhi_ft_s =  fourierTransform_transmitted.d_Phi_ElectricFieldStrength{1};
dPhi_ft_p =  fourierTransform_transmitted.d_Phi_ElectricFieldStrength{2};

% PatternWidthTop-derivatives of the Fourier coefficients of the two fields
dPatternWidthTop_ft_s =  fourierTransform_transmitted.d_PatternWidthTop_ElectricFieldStrength{1};
dPatternWidthTop_ft_p =  fourierTransform_transmitted.d_PatternWidthTop_ElectricFieldStrength{2};

% PatternHeight-derivatives of the Fourier coefficients of the two fields
dPatternHeight_ft_s =  fourierTransform_transmitted.d_PatternHeight_ElectricFieldStrength{1};
dPatternHeight_ft_p =  fourierTransform_transmitted.d_PatternHeight_ElectricFieldStrength{2};

Note

For demonstration purposes the script data_analysis/compare_diff_quotient.m compares the automatically computed derivatives with a numerical differentiation based on a difference quotient.

Note

The built-in automatic differentiation is faster and more accurate than the numerical differentiation based on difference quotients.