- etaseta order parametersC++ Type:std::vector<VariableName> Unit:(no unit assumed) Controllable:No Description:eta order parameters 
- variableThe name of the variable that this residual object operates onC++ Type:NonlinearVariableName Unit:(no unit assumed) Controllable:No Description:The name of the variable that this residual object operates on 
SwitchingFunctionConstraintLagrange
Lagrange multiplier kernel to constrain the sum of all switching functions in a multiphase system. This kernel acts on the Lagrange multiplier variable.
Enforces the constraint . See Multiphase models for the full derivation.
Input Parameters
- blockThe list of blocks (ids or names) that this object will be appliedC++ Type:std::vector<SubdomainName> Controllable:No Description:The list of blocks (ids or names) that this object will be applied 
- displacementsThe displacementsC++ Type:std::vector<VariableName> Unit:(no unit assumed) Controllable:No Description:The displacements 
- epsilon1e-09Shift factor to avoid a zero pivotDefault:1e-09 C++ Type:double Unit:(no unit assumed) Controllable:No Description:Shift factor to avoid a zero pivot 
- h_namesSwitching function materialsC++ Type:std::vector<MaterialPropertyName> Unit:(no unit assumed) Controllable:No Description:Switching function materials 
- matrix_onlyFalseWhether this object is only doing assembly to matrices (no vectors)Default:False C++ Type:bool Controllable:No Description:Whether this object is only doing assembly to matrices (no vectors) 
Optional Parameters
- absolute_value_vector_tagsThe tags for the vectors this residual object should fill with the absolute value of the residual contributionC++ Type:std::vector<TagName> Controllable:No Description:The tags for the vectors this residual object should fill with the absolute value of the residual contribution 
- extra_matrix_tagsThe extra tags for the matrices this Kernel should fillC++ Type:std::vector<TagName> Controllable:No Description:The extra tags for the matrices this Kernel should fill 
- extra_vector_tagsThe extra tags for the vectors this Kernel should fillC++ Type:std::vector<TagName> Controllable:No Description:The extra tags for the vectors this Kernel should fill 
- matrix_tagssystemThe tag for the matrices this Kernel should fillDefault:system C++ Type:MultiMooseEnum Options:nontime, system Controllable:No Description:The tag for the matrices this Kernel should fill 
- vector_tagsnontimeThe tag for the vectors this Kernel should fillDefault:nontime C++ Type:MultiMooseEnum Options:nontime, time Controllable:No Description:The tag for the vectors this Kernel should fill 
Contribution To Tagged Field Data Parameters
- control_tagsAdds user-defined labels for accessing object parameters via control logic.C++ Type:std::vector<std::string> Controllable:No Description:Adds user-defined labels for accessing object parameters via control logic. 
- diag_save_inThe name of auxiliary variables to save this Kernel's diagonal Jacobian contributions to. Everything about that variable must match everything about this variable (the type, what blocks it's on, etc.)C++ Type:std::vector<AuxVariableName> Unit:(no unit assumed) Controllable:No Description:The name of auxiliary variables to save this Kernel's diagonal Jacobian contributions to. Everything about that variable must match everything about this variable (the type, what blocks it's on, etc.) 
- enableTrueSet the enabled status of the MooseObject.Default:True C++ Type:bool Controllable:Yes Description:Set the enabled status of the MooseObject. 
- implicitTrueDetermines whether this object is calculated using an implicit or explicit formDefault:True C++ Type:bool Controllable:No Description:Determines whether this object is calculated using an implicit or explicit form 
- save_inThe name of auxiliary variables to save this Kernel's residual contributions to. Everything about that variable must match everything about this variable (the type, what blocks it's on, etc.)C++ Type:std::vector<AuxVariableName> Unit:(no unit assumed) Controllable:No Description:The name of auxiliary variables to save this Kernel's residual contributions to. Everything about that variable must match everything about this variable (the type, what blocks it's on, etc.) 
- search_methodnearest_node_connected_sidesChoice of search algorithm. All options begin by finding the nearest node in the primary boundary to a query point in the secondary boundary. In the default nearest_node_connected_sides algorithm, primary boundary elements are searched iff that nearest node is one of their nodes. This is fast to determine via a pregenerated node-to-elem map and is robust on conforming meshes. In the optional all_proximate_sides algorithm, primary boundary elements are searched iff they touch that nearest node, even if they are not topologically connected to it. This is more CPU-intensive but is necessary for robustness on any boundary surfaces which has disconnections (such as Flex IGA meshes) or non-conformity (such as hanging nodes in adaptively h-refined meshes).Default:nearest_node_connected_sides C++ Type:MooseEnum Options:nearest_node_connected_sides, all_proximate_sides Controllable:No Description:Choice of search algorithm. All options begin by finding the nearest node in the primary boundary to a query point in the secondary boundary. In the default nearest_node_connected_sides algorithm, primary boundary elements are searched iff that nearest node is one of their nodes. This is fast to determine via a pregenerated node-to-elem map and is robust on conforming meshes. In the optional all_proximate_sides algorithm, primary boundary elements are searched iff they touch that nearest node, even if they are not topologically connected to it. This is more CPU-intensive but is necessary for robustness on any boundary surfaces which has disconnections (such as Flex IGA meshes) or non-conformity (such as hanging nodes in adaptively h-refined meshes). 
- seed0The seed for the master random number generatorDefault:0 C++ Type:unsigned int Controllable:No Description:The seed for the master random number generator 
- use_displaced_meshFalseWhether or not this object should use the displaced mesh for computation. Note that in the case this is true but no displacements are provided in the Mesh block the undisplaced mesh will still be used.Default:False C++ Type:bool Controllable:No Description:Whether or not this object should use the displaced mesh for computation. Note that in the case this is true but no displacements are provided in the Mesh block the undisplaced mesh will still be used. 
Advanced Parameters
- prop_getter_suffixAn optional suffix parameter that can be appended to any attempt to retrieve/get material properties. The suffix will be prepended with a '_' character.C++ Type:MaterialPropertyName Unit:(no unit assumed) Controllable:No Description:An optional suffix parameter that can be appended to any attempt to retrieve/get material properties. The suffix will be prepended with a '_' character. 
- use_interpolated_stateFalseFor the old and older state use projected material properties interpolated at the quadrature points. To set up projection use the ProjectedStatefulMaterialStorageAction.Default:False C++ Type:bool Controllable:No Description:For the old and older state use projected material properties interpolated at the quadrature points. To set up projection use the ProjectedStatefulMaterialStorageAction. 
Material Property Retrieval Parameters
Input Files
- (modules/phase_field/test/tests/MultiPhase/acmultiinterface_aux.i)
- (modules/phase_field/examples/slkks/CrFe.i)
- (modules/phase_field/test/tests/MultiPhase/lagrangemult.i)
- (modules/phase_field/test/tests/KKS_system/kks_example_multiphase_nested_damped.i)
- (modules/combined/examples/publications/rapid_dev/fig8.i)
- (modules/phase_field/test/tests/KKS_system/kks_example_multiphase_nested.i)
- (modules/phase_field/test/tests/slkks/full_solve.i)
- (modules/combined/examples/phase_field-mechanics/Pattern1.i)
- (modules/phase_field/test/tests/MultiPhase/acmultiinterface.i)
(modules/phase_field/test/tests/MultiPhase/acmultiinterface_aux.i)
[Mesh]
  type = GeneratedMesh
  dim = 2
  nx = 20
  ny = 10
  nz = 0
  xmin = -10
  xmax = 10
  ymin = -5
  ymax = 5
  elem_type = QUAD4
[]
[AuxVariables]
  [./eta1]
    order = FIRST
    family = LAGRANGE
    [./InitialCondition]
      type = SmoothCircleIC
      x1 = -3.5
      y1 =  0.0
      radius = 4.0
      invalue = 0.9
      outvalue = 0.1
      int_width = 2.0
    [../]
  [../]
[]
[Variables]
  [./eta2]
    order = FIRST
    family = LAGRANGE
    [./InitialCondition]
      type = SmoothCircleIC
      x1 =  3.5
      y1 =  0.0
      radius = 4.0
      invalue = 0.9
      outvalue = 0.1
      int_width = 2.0
    [../]
  [../]
  [./eta3]
    order = FIRST
    family = LAGRANGE
    [./InitialCondition]
      type = SpecifiedSmoothCircleIC
      x_positions = '-4.0 4.0'
      y_positions = ' 0.0 0.0'
      z_positions = ' 0.0 0.0'
      radii = '4.0 4.0'
      invalue = 0.1
      outvalue = 0.9
      int_width = 2.0
    [../]
  [../]
  [./lambda]
    order = FIRST
    family = LAGRANGE
    initial_condition = 1.0
  [../]
[]
[Kernels]
  [./deta2dt]
    type = TimeDerivative
    variable = eta2
  [../]
  [./ACBulk2]
    type = AllenCahn
    variable = eta2
    coupled_variables = 'eta1 eta3'
    mob_name = L2
    f_name = F
  [../]
  [./ACInterface2]
    type = ACMultiInterface
    variable = eta2
    etas = 'eta1 eta2 eta3'
    mob_name = L2
    kappa_names = 'kappa21 kappa22 kappa23'
  [../]
  [./lagrange2]
    type = SwitchingFunctionConstraintEta
    variable = eta2
    h_name   = h2
    lambda = lambda
  [../]
  [./deta3dt]
    type = TimeDerivative
    variable = eta3
  [../]
  [./ACBulk3]
    type = AllenCahn
    variable = eta3
    coupled_variables = 'eta1 eta2'
    mob_name = L3
    f_name = F
  [../]
  [./ACInterface3]
    type = ACMultiInterface
    variable = eta3
    etas = 'eta1 eta2 eta3'
    mob_name = L3
    kappa_names = 'kappa31 kappa32 kappa33'
  [../]
  [./lagrange3]
    type = SwitchingFunctionConstraintEta
    variable = eta3
    h_name   = h3
    lambda = lambda
  [../]
  [./lagrange]
    type = SwitchingFunctionConstraintLagrange
    variable = lambda
    etas    = 'eta1 eta2 eta3'
    h_names = 'h1   h2   h3'
    epsilon = 0
  [../]
[]
[BCs]
  [./Periodic]
    [./All]
      auto_direction = 'x y'
    [../]
  [../]
[]
[Materials]
  [./consts]
    type = GenericConstantMaterial
    prop_names  = 'Fx  L1 L2 L3  kappa11 kappa12 kappa13 kappa21 kappa22 kappa23 kappa31 kappa32 kappa33'
    prop_values = '0   1  1  1   1       1       1       1       1       1       1       1       1      '
  [../]
  [./switching1]
    type = SwitchingFunctionMaterial
    function_name = h1
    eta = eta1
    h_order = SIMPLE
  [../]
  [./switching2]
    type = SwitchingFunctionMaterial
    function_name = h2
    eta = eta2
    h_order = SIMPLE
  [../]
  [./switching3]
    type = SwitchingFunctionMaterial
    function_name = h3
    eta = eta3
    h_order = SIMPLE
  [../]
  [./barrier]
    type = MultiBarrierFunctionMaterial
    etas = 'eta1 eta2 eta3'
  [../]
  [./free_energy]
    type = DerivativeMultiPhaseMaterial
    property_name = F
    # we use a constant free energy (GeneriConstantmaterial property Fx)
    fi_names = 'Fx  Fx  Fx'
    hi_names = 'h1  h2  h3'
    etas     = 'eta1 eta2 eta3'
    # the free energy is given by the MultiBarrierFunctionMaterial only
    W = 1
    derivative_order = 2
  [../]
[]
[Preconditioning]
  [./SMP]
    type = SMP
    full = true
  [../]
[]
[Executioner]
  type = Transient
  scheme = 'bdf2'
  solve_type = 'PJFNK'
  #petsc_options = '-snes_ksp -snes_ksp_ew'
  #petsc_options = '-ksp_monitor_snes_lg-snes_ksp_ew'
  #petsc_options_iname = '-ksp_gmres_restart'
  #petsc_options_value = '1000              '
  l_max_its = 15
  l_tol = 1.0e-6
  nl_max_its = 50
  nl_rel_tol = 1.0e-8
  nl_abs_tol = 1.0e-10
  start_time = 0.0
  num_steps = 2
  dt = 0.2
[]
[Outputs]
  execute_on = 'timestep_end'
  exodus = true
[]
(modules/phase_field/examples/slkks/CrFe.i)
#
# SLKKS two phase example for the BCC and SIGMA phases. The sigma phase contains
# multiple sublattices. Free energy from
# Jacob, Aurelie, Erwin Povoden-Karadeniz, and Ernst Kozeschnik. "Revised thermodynamic
# description of the Fe-Cr system based on an improved sublattice model of the sigma phase."
# Calphad 60 (2018): 16-28.
#
# In this simulation we consider diffusion (Cahn-Hilliard) and phase transformation.
#
# This example requires CrFe_sigma_out_var_0001.csv file, which generated by first
# running the CrFe_sigma.i input file.
[Mesh]
  [gen]
    type = GeneratedMeshGenerator
    dim = 2
    nx = 160
    ny = 1
    nz = 0
    xmin = -25
    xmax = 25
    ymin = -2.5
    ymax = 2.5
    elem_type = QUAD4
  []
[]
[AuxVariables]
  [Fglobal]
    order = CONSTANT
    family = MONOMIAL
  []
[]
[Functions]
  [sigma_cr0]
    type = PiecewiseLinear
    data_file = CrFe_sigma_out_var_0001.csv
    format = columns
    x_index_in_file = 5
    y_index_in_file = 2
    xy_in_file_only = false
  []
  [sigma_cr1]
    type = PiecewiseLinear
    data_file = CrFe_sigma_out_var_0001.csv
    format = columns
    x_index_in_file = 5
    y_index_in_file = 3
    xy_in_file_only = false
  []
  [sigma_cr2]
    type = PiecewiseLinear
    data_file = CrFe_sigma_out_var_0001.csv
    format = columns
    x_index_in_file = 5
    y_index_in_file = 4
    xy_in_file_only = false
  []
[]
[Variables]
  # order parameters
  [eta1]
    order = FIRST
    family = LAGRANGE
    initial_condition = 0.5
  []
  [eta2]
    order = FIRST
    family = LAGRANGE
    initial_condition = 0.5
  []
  # solute concentration
  [cCr]
    order = FIRST
    family = LAGRANGE
    [InitialCondition]
      type = FunctionIC
      function = '(x+25)/50*0.5+0.1'
    []
  []
  # sublattice concentrations
  [BCC_CR]
    initial_condition = 0.45
  []
  [SIGMA_0CR]
    [InitialCondition]
      type = CoupledValueFunctionIC
      function = sigma_cr0
      v = cCr
      variable = SIGMA_0CR
    []
  []
  [SIGMA_1CR]
    [InitialCondition]
      type = CoupledValueFunctionIC
      function = sigma_cr1
      v = cCr
      variable = SIGMA_1CR
    []
  []
  [SIGMA_2CR]
    [InitialCondition]
      type = CoupledValueFunctionIC
      function = sigma_cr2
      v = cCr
      variable = SIGMA_2CR
    []
  []
  # Lagrange multiplier
  [lambda]
  []
[]
[Materials]
  # CALPHAD free energies
  [F_BCC_A2]
    type = DerivativeParsedMaterial
    property_name = F_BCC_A2
    outputs = exodus
    output_properties = F_BCC_A2
    expression = 'BCC_FE:=1-BCC_CR; G := 8.3145*T*(1.0*if(BCC_CR > 1.0e-15,BCC_CR*log(BCC_CR),0) + '
               '1.0*if(BCC_FE > 1.0e-15,BCC_FE*plog(BCC_FE,eps),0) + 3.0*if(BCC_VA > '
               '1.0e-15,BCC_VA*log(BCC_VA),0))/(BCC_CR + BCC_FE) + 8.3145*T*if(T < '
               '548.2*BCC_CR*BCC_FE*BCC_VA*(BCC_CR - BCC_FE) - 932.5*BCC_CR*BCC_FE*BCC_VA + '
               '311.5*BCC_CR*BCC_VA - '
               '1043.0*BCC_FE*BCC_VA,-8.13674105561218e-49*T^15/(0.525599232981783*BCC_CR*BCC_FE*BCC_'
               'VA*(BCC_CR - BCC_FE) - 0.894055608820709*BCC_CR*BCC_FE*BCC_VA + '
               '0.298657718120805*BCC_CR*BCC_VA - BCC_FE*BCC_VA + 9.58772770853308e-13)^15 - '
               '4.65558036243985e-30*T^9/(0.525599232981783*BCC_CR*BCC_FE*BCC_VA*(BCC_CR - BCC_FE) - '
               '0.894055608820709*BCC_CR*BCC_FE*BCC_VA + 0.298657718120805*BCC_CR*BCC_VA - '
               'BCC_FE*BCC_VA + 9.58772770853308e-13)^9 - '
               '1.3485349181899e-10*T^3/(0.525599232981783*BCC_CR*BCC_FE*BCC_VA*(BCC_CR - BCC_FE) - '
               '0.894055608820709*BCC_CR*BCC_FE*BCC_VA + 0.298657718120805*BCC_CR*BCC_VA - '
               'BCC_FE*BCC_VA + 9.58772770853308e-13)^3 + 1 - '
               '0.905299382744392*(548.2*BCC_CR*BCC_FE*BCC_VA*(BCC_CR - BCC_FE) - '
               '932.5*BCC_CR*BCC_FE*BCC_VA + 311.5*BCC_CR*BCC_VA - 1043.0*BCC_FE*BCC_VA + '
               '1.0e-9)/T,if(T < -548.2*BCC_CR*BCC_FE*BCC_VA*(BCC_CR - BCC_FE) + '
               '932.5*BCC_CR*BCC_FE*BCC_VA - 311.5*BCC_CR*BCC_VA + '
               '1043.0*BCC_FE*BCC_VA,-8.13674105561218e-49*T^15/(-0.525599232981783*BCC_CR*BCC_FE*BCC'
               '_VA*(BCC_CR - BCC_FE) + 0.894055608820709*BCC_CR*BCC_FE*BCC_VA - '
               '0.298657718120805*BCC_CR*BCC_VA + BCC_FE*BCC_VA + 9.58772770853308e-13)^15 - '
               '4.65558036243985e-30*T^9/(-0.525599232981783*BCC_CR*BCC_FE*BCC_VA*(BCC_CR - BCC_FE) '
               '+ 0.894055608820709*BCC_CR*BCC_FE*BCC_VA - 0.298657718120805*BCC_CR*BCC_VA + '
               'BCC_FE*BCC_VA + 9.58772770853308e-13)^9 - '
               '1.3485349181899e-10*T^3/(-0.525599232981783*BCC_CR*BCC_FE*BCC_VA*(BCC_CR - BCC_FE) + '
               '0.894055608820709*BCC_CR*BCC_FE*BCC_VA - 0.298657718120805*BCC_CR*BCC_VA + '
               'BCC_FE*BCC_VA + 9.58772770853308e-13)^3 + 1 - '
               '0.905299382744392*(-548.2*BCC_CR*BCC_FE*BCC_VA*(BCC_CR - BCC_FE) + '
               '932.5*BCC_CR*BCC_FE*BCC_VA - 311.5*BCC_CR*BCC_VA + 1043.0*BCC_FE*BCC_VA + '
               '1.0e-9)/T,if(T > -548.2*BCC_CR*BCC_FE*BCC_VA*(BCC_CR - BCC_FE) + '
               '932.5*BCC_CR*BCC_FE*BCC_VA - 311.5*BCC_CR*BCC_VA + 1043.0*BCC_FE*BCC_VA & '
               '548.2*BCC_CR*BCC_FE*BCC_VA*(BCC_CR - BCC_FE) - 932.5*BCC_CR*BCC_FE*BCC_VA + '
               '311.5*BCC_CR*BCC_VA - 1043.0*BCC_FE*BCC_VA < '
               '0,-79209031311018.7*(-0.525599232981783*BCC_CR*BCC_FE*BCC_VA*(BCC_CR - BCC_FE) + '
               '0.894055608820709*BCC_CR*BCC_FE*BCC_VA - 0.298657718120805*BCC_CR*BCC_VA + '
               'BCC_FE*BCC_VA + 9.58772770853308e-13)^5/T^5 - '
               '3.83095660520737e+42*(-0.525599232981783*BCC_CR*BCC_FE*BCC_VA*(BCC_CR - BCC_FE) + '
               '0.894055608820709*BCC_CR*BCC_FE*BCC_VA - 0.298657718120805*BCC_CR*BCC_VA + '
               'BCC_FE*BCC_VA + 9.58772770853308e-13)^15/T^15 - '
               '1.22565886734485e+72*(-0.525599232981783*BCC_CR*BCC_FE*BCC_VA*(BCC_CR - BCC_FE) + '
               '0.894055608820709*BCC_CR*BCC_FE*BCC_VA - 0.298657718120805*BCC_CR*BCC_VA + '
               'BCC_FE*BCC_VA + 9.58772770853308e-13)^25/T^25,if(T > '
               '548.2*BCC_CR*BCC_FE*BCC_VA*(BCC_CR - BCC_FE) - 932.5*BCC_CR*BCC_FE*BCC_VA + '
               '311.5*BCC_CR*BCC_VA - 1043.0*BCC_FE*BCC_VA & 548.2*BCC_CR*BCC_FE*BCC_VA*(BCC_CR - '
               'BCC_FE) - 932.5*BCC_CR*BCC_FE*BCC_VA + 311.5*BCC_CR*BCC_VA - 1043.0*BCC_FE*BCC_VA > '
               '0,-79209031311018.7*(0.525599232981783*BCC_CR*BCC_FE*BCC_VA*(BCC_CR - BCC_FE) - '
               '0.894055608820709*BCC_CR*BCC_FE*BCC_VA + 0.298657718120805*BCC_CR*BCC_VA - '
               'BCC_FE*BCC_VA + 9.58772770853308e-13)^5/T^5 - '
               '3.83095660520737e+42*(0.525599232981783*BCC_CR*BCC_FE*BCC_VA*(BCC_CR - BCC_FE) - '
               '0.894055608820709*BCC_CR*BCC_FE*BCC_VA + 0.298657718120805*BCC_CR*BCC_VA - '
               'BCC_FE*BCC_VA + 9.58772770853308e-13)^15/T^15 - '
               '1.22565886734485e+72*(0.525599232981783*BCC_CR*BCC_FE*BCC_VA*(BCC_CR - BCC_FE) - '
               '0.894055608820709*BCC_CR*BCC_FE*BCC_VA + 0.298657718120805*BCC_CR*BCC_VA - '
               'BCC_FE*BCC_VA + 9.58772770853308e-13)^25/T^25,0))))*log((2.15*BCC_CR*BCC_FE*BCC_VA - '
               '0.008*BCC_CR*BCC_VA + 2.22*BCC_FE*BCC_VA)*if(2.15*BCC_CR*BCC_FE*BCC_VA - '
               '0.008*BCC_CR*BCC_VA + 2.22*BCC_FE*BCC_VA <= 0,-1.0,1.0) + 1)/(BCC_CR + BCC_FE) + '
               '1.0*(BCC_CR*BCC_VA*if(T >= 298.15 & T < 2180.0,139250.0*1/T - 26.908*T*log(T) + '
               '157.48*T + 0.00189435*T^2.0 - 1.47721e-6*T^3.0 - 8856.94,if(T >= 2180.0 & T < '
               '6000.0,-2.88526e+32*T^(-9.0) - 50.0*T*log(T) + 344.18*T - 34869.344,0)) + '
               'BCC_FE*BCC_VA*if(T >= 298.15 & T < 1811.0,77358.5*1/T - 23.5143*T*log(T) + 124.134*T '
               '- 0.00439752*T^2.0 - 5.89269e-8*T^3.0 + 1225.7,if(T >= 1811.0 & T < '
               '6000.0,2.2960305e+31*T^(-9.0) - 46.0*T*log(T) + 299.31255*T - 25383.581,0)))/(BCC_CR '
               '+ BCC_FE) + 1.0*(BCC_CR*BCC_FE*BCC_VA*(500.0 - 1.5*T)*(BCC_CR - BCC_FE) + '
               'BCC_CR*BCC_FE*BCC_VA*(24600.0 - 14.98*T) + BCC_CR*BCC_FE*BCC_VA*(9.15*T - '
               '14000.0)*(BCC_CR - BCC_FE)^2)/(BCC_CR + BCC_FE); G/100000'
    coupled_variables = 'BCC_CR'
    constant_names = 'BCC_VA T eps'
    constant_expressions = '1 1000 0.01'
  []
  [F_SIGMA]
    type = DerivativeParsedMaterial
    property_name = F_SIGMA
    outputs = exodus
    output_properties = F_SIGMA
    expression = 'SIGMA_0FE := 1-SIGMA_0CR; SIGMA_1FE := 1-SIGMA_1CR; SIGMA_2FE := 1-SIGMA_2CR; G := '
               '8.3145*T*(10.0*if(SIGMA_0CR > 1.0e-15,SIGMA_0CR*plog(SIGMA_0CR,eps),0) + '
               '10.0*if(SIGMA_0FE > 1.0e-15,SIGMA_0FE*plog(SIGMA_0FE,eps),0) + 4.0*if(SIGMA_1CR > '
               '1.0e-15,SIGMA_1CR*plog(SIGMA_1CR,eps),0) + 4.0*if(SIGMA_1FE > '
               '1.0e-15,SIGMA_1FE*plog(SIGMA_1FE,eps),0) + 16.0*if(SIGMA_2CR > '
               '1.0e-15,SIGMA_2CR*plog(SIGMA_2CR,eps),0) + 16.0*if(SIGMA_2FE > '
               '1.0e-15,SIGMA_2FE*plog(SIGMA_2FE,eps),0))/(10.0*SIGMA_0CR + 10.0*SIGMA_0FE + '
               '4.0*SIGMA_1CR + 4.0*SIGMA_1FE + 16.0*SIGMA_2CR + 16.0*SIGMA_2FE) + '
               '(SIGMA_0FE*SIGMA_1CR*SIGMA_2CR*SIGMA_2FE*(-70.0*T - 170400.0) + '
               'SIGMA_0FE*SIGMA_1FE*SIGMA_2CR*SIGMA_2FE*(-10.0*T - 330839.0))/(10.0*SIGMA_0CR + '
               '10.0*SIGMA_0FE + 4.0*SIGMA_1CR + 4.0*SIGMA_1FE + 16.0*SIGMA_2CR + 16.0*SIGMA_2FE) + '
               '(SIGMA_0CR*SIGMA_1CR*SIGMA_2CR*(30.0*if(T >= 298.15 & T < 2180.0,139250.0*1/T - '
               '26.908*T*log(T) + 157.48*T + 0.00189435*T^2.0 - 1.47721e-6*T^3.0 - 8856.94,if(T >= '
               '2180.0 & T < 6000.0,-2.88526e+32*T^(-9.0) - 50.0*T*log(T) + 344.18*T - 34869.344,0)) '
               '+ 132000.0) + SIGMA_0CR*SIGMA_1CR*SIGMA_2FE*(-110.0*T + 16.0*if(T >= 298.15 & T < '
               '1811.0,77358.5*1/T - 23.5143*T*log(T) + 124.134*T - 0.00439752*T^2.0 - '
               '5.89269e-8*T^3.0 + 1225.7,if(T >= 1811.0 & T < 6000.0,2.2960305e+31*T^(-9.0) - '
               '46.0*T*log(T) + 299.31255*T - 25383.581,0)) + 14.0*if(T >= 298.15 & T < '
               '2180.0,139250.0*1/T - 26.908*T*log(T) + 157.48*T + 0.00189435*T^2.0 - '
               '1.47721e-6*T^3.0 - 8856.94,if(T >= 2180.0 & T < 6000.0,-2.88526e+32*T^(-9.0) - '
               '50.0*T*log(T) + 344.18*T - 34869.344,0)) + 123500.0) + '
               'SIGMA_0CR*SIGMA_1FE*SIGMA_2CR*(4.0*if(T >= 298.15 & T < 1811.0,77358.5*1/T - '
               '23.5143*T*log(T) + 124.134*T - 0.00439752*T^2.0 - 5.89269e-8*T^3.0 + 1225.7,if(T >= '
               '1811.0 & T < 6000.0,2.2960305e+31*T^(-9.0) - 46.0*T*log(T) + 299.31255*T - '
               '25383.581,0)) + 26.0*if(T >= 298.15 & T < 2180.0,139250.0*1/T - 26.908*T*log(T) + '
               '157.48*T + 0.00189435*T^2.0 - 1.47721e-6*T^3.0 - 8856.94,if(T >= 2180.0 & T < '
               '6000.0,-2.88526e+32*T^(-9.0) - 50.0*T*log(T) + 344.18*T - 34869.344,0)) + 140486.0) '
               '+ SIGMA_0CR*SIGMA_1FE*SIGMA_2FE*(20.0*if(T >= 298.15 & T < 1811.0,77358.5*1/T - '
               '23.5143*T*log(T) + 124.134*T - 0.00439752*T^2.0 - 5.89269e-8*T^3.0 + 1225.7,if(T >= '
               '1811.0 & T < 6000.0,2.2960305e+31*T^(-9.0) - 46.0*T*log(T) + 299.31255*T - '
               '25383.581,0)) + 10.0*if(T >= 298.15 & T < 2180.0,139250.0*1/T - 26.908*T*log(T) + '
               '157.48*T + 0.00189435*T^2.0 - 1.47721e-6*T^3.0 - 8856.94,if(T >= 2180.0 & T < '
               '6000.0,-2.88526e+32*T^(-9.0) - 50.0*T*log(T) + 344.18*T - 34869.344,0)) + 148800.0) '
               '+ SIGMA_0FE*SIGMA_1CR*SIGMA_2CR*(10.0*if(T >= 298.15 & T < 1811.0,77358.5*1/T - '
               '23.5143*T*log(T) + 124.134*T - 0.00439752*T^2.0 - 5.89269e-8*T^3.0 + 1225.7,if(T >= '
               '1811.0 & T < 6000.0,2.2960305e+31*T^(-9.0) - 46.0*T*log(T) + 299.31255*T - '
               '25383.581,0)) + 20.0*if(T >= 298.15 & T < 2180.0,139250.0*1/T - 26.908*T*log(T) + '
               '157.48*T + 0.00189435*T^2.0 - 1.47721e-6*T^3.0 - 8856.94,if(T >= 2180.0 & T < '
               '6000.0,-2.88526e+32*T^(-9.0) - 50.0*T*log(T) + 344.18*T - 34869.344,0)) + 56200.0) + '
               'SIGMA_0FE*SIGMA_1CR*SIGMA_2FE*(26.0*if(T >= 298.15 & T < 1811.0,77358.5*1/T - '
               '23.5143*T*log(T) + 124.134*T - 0.00439752*T^2.0 - 5.89269e-8*T^3.0 + 1225.7,if(T >= '
               '1811.0 & T < 6000.0,2.2960305e+31*T^(-9.0) - 46.0*T*log(T) + 299.31255*T - '
               '25383.581,0)) + 4.0*if(T >= 298.15 & T < 2180.0,139250.0*1/T - 26.908*T*log(T) + '
               '157.48*T + 0.00189435*T^2.0 - 1.47721e-6*T^3.0 - 8856.94,if(T >= 2180.0 & T < '
               '6000.0,-2.88526e+32*T^(-9.0) - 50.0*T*log(T) + 344.18*T - 34869.344,0)) + 152700.0) '
               '+ SIGMA_0FE*SIGMA_1FE*SIGMA_2CR*(14.0*if(T >= 298.15 & T < 1811.0,77358.5*1/T - '
               '23.5143*T*log(T) + 124.134*T - 0.00439752*T^2.0 - 5.89269e-8*T^3.0 + 1225.7,if(T >= '
               '1811.0 & T < 6000.0,2.2960305e+31*T^(-9.0) - 46.0*T*log(T) + 299.31255*T - '
               '25383.581,0)) + 16.0*if(T >= 298.15 & T < 2180.0,139250.0*1/T - 26.908*T*log(T) + '
               '157.48*T + 0.00189435*T^2.0 - 1.47721e-6*T^3.0 - 8856.94,if(T >= 2180.0 & T < '
               '6000.0,-2.88526e+32*T^(-9.0) - 50.0*T*log(T) + 344.18*T - 34869.344,0)) + 46200.0) + '
               'SIGMA_0FE*SIGMA_1FE*SIGMA_2FE*(30.0*if(T >= 298.15 & T < 1811.0,77358.5*1/T - '
               '23.5143*T*log(T) + 124.134*T - 0.00439752*T^2.0 - 5.89269e-8*T^3.0 + 1225.7,if(T >= '
               '1811.0 & T < 6000.0,2.2960305e+31*T^(-9.0) - 46.0*T*log(T) + 299.31255*T - '
               '25383.581,0)) + 173333.0))/(10.0*SIGMA_0CR + 10.0*SIGMA_0FE + 4.0*SIGMA_1CR + '
               '4.0*SIGMA_1FE + 16.0*SIGMA_2CR + 16.0*SIGMA_2FE); G/100000'
    coupled_variables = 'SIGMA_0CR SIGMA_1CR SIGMA_2CR'
    constant_names = 'T eps'
    constant_expressions = '1000 0.01'
  []
  # h(eta)
  [h1]
    type = SwitchingFunctionMaterial
    function_name = h1
    h_order = HIGH
    eta = eta1
  []
  [h2]
    type = SwitchingFunctionMaterial
    function_name = h2
    h_order = HIGH
    eta = eta2
  []
  # g(eta)
  [g1]
    type = BarrierFunctionMaterial
    function_name = g1
    g_order = SIMPLE
    eta = eta1
  []
  [g2]
    type = BarrierFunctionMaterial
    function_name = g2
    g_order = SIMPLE
    eta = eta2
  []
  # constant properties
  [constants]
    type = GenericConstantMaterial
    prop_names = 'D   L   kappa'
    prop_values = '10  1   0.1  '
  []
  # Coefficients for diffusion equation
  [Dh1]
    type = DerivativeParsedMaterial
    material_property_names = 'D h1(eta1)'
    expression = D*h1
    property_name = Dh1
    coupled_variables = eta1
    derivative_order = 1
  []
  [Dh2a]
    type = DerivativeParsedMaterial
    material_property_names = 'D h2(eta2)'
    expression = D*h2*10/30
    property_name = Dh2a
    coupled_variables = eta2
    derivative_order = 1
  []
  [Dh2b]
    type = DerivativeParsedMaterial
    material_property_names = 'D h2(eta2)'
    expression = D*h2*4/30
    property_name = Dh2b
    coupled_variables = eta2
    derivative_order = 1
  []
  [Dh2c]
    type = DerivativeParsedMaterial
    material_property_names = 'D h2(eta2)'
    expression = D*h2*16/30
    property_name = Dh2c
    coupled_variables = eta2
    derivative_order = 1
  []
[]
[Kernels]
  #Kernels for diffusion equation
  [diff_time]
    type = TimeDerivative
    variable = cCr
  []
  [diff_c1]
    type = MatDiffusion
    variable = cCr
    diffusivity = Dh1
    v = BCC_CR
    args = eta1
  []
  [diff_c2a]
    type = MatDiffusion
    variable = cCr
    diffusivity = Dh2a
    v = SIGMA_0CR
    args = eta2
  []
  [diff_c2b]
    type = MatDiffusion
    variable = cCr
    diffusivity = Dh2b
    v = SIGMA_1CR
    args = eta2
  []
  [diff_c2c]
    type = MatDiffusion
    variable = cCr
    diffusivity = Dh2c
    v = SIGMA_2CR
    args = eta2
  []
  # enforce pointwise equality of chemical potentials
  [chempot1a2a]
    # The BCC phase has only one sublattice
    # we tie it to the first sublattice with site fraction 10/(10+4+16) in the sigma phase
    type = KKSPhaseChemicalPotential
    variable = BCC_CR
    cb = SIGMA_0CR
    kb = '${fparse 10/30}'
    fa_name = F_BCC_A2
    fb_name = F_SIGMA
    args_b = 'SIGMA_1CR SIGMA_2CR'
  []
  [chempot2a2b]
    # This kernel ties the first two sublattices in the sigma phase together
    type = SLKKSChemicalPotential
    variable = SIGMA_0CR
    a = 10
    cs = SIGMA_1CR
    as = 4
    F = F_SIGMA
    coupled_variables = 'SIGMA_2CR'
  []
  [chempot2b2c]
    # This kernel ties the remaining two sublattices in the sigma phase together
    type = SLKKSChemicalPotential
    variable = SIGMA_1CR
    a = 4
    cs = SIGMA_2CR
    as = 16
    F = F_SIGMA
    coupled_variables = 'SIGMA_0CR'
  []
  [phaseconcentration]
    # This kernel ties the sum of the sublattice concentrations to the global concentration cCr
    type = SLKKSMultiPhaseConcentration
    variable = SIGMA_2CR
    c = cCr
    ns = '1      3'
    as = '1      10        4         16'
    cs = 'BCC_CR SIGMA_0CR SIGMA_1CR SIGMA_2CR'
    h_names = 'h1   h2'
    eta = 'eta1 eta2'
  []
  # Kernels for Allen-Cahn equation for eta1
  [deta1dt]
    type = TimeDerivative
    variable = eta1
  []
  [ACBulkF1]
    type = KKSMultiACBulkF
    variable = eta1
    Fj_names = 'F_BCC_A2 F_SIGMA'
    hj_names = 'h1    h2'
    gi_name = g1
    eta_i = eta1
    wi = 0.1
    coupled_variables = 'BCC_CR SIGMA_0CR SIGMA_1CR SIGMA_2CR eta2'
  []
  [ACBulkC1]
    type = SLKKSMultiACBulkC
    variable = eta1
    F = F_BCC_A2
    c = BCC_CR
    ns = '1      3'
    as = '1      10        4         16'
    cs = 'BCC_CR SIGMA_0CR SIGMA_1CR SIGMA_2CR'
    h_names = 'h1   h2'
    eta = 'eta1 eta2'
  []
  [ACInterface1]
    type = ACInterface
    variable = eta1
    kappa_name = kappa
  []
  [lagrange1]
    type = SwitchingFunctionConstraintEta
    variable = eta1
    h_name = h1
    lambda = lambda
    coupled_variables = 'eta2'
  []
  # Kernels for Allen-Cahn equation for eta1
  [deta2dt]
    type = TimeDerivative
    variable = eta2
  []
  [ACBulkF2]
    type = KKSMultiACBulkF
    variable = eta2
    Fj_names = 'F_BCC_A2 F_SIGMA'
    hj_names = 'h1    h2'
    gi_name = g2
    eta_i = eta2
    wi = 0.1
    coupled_variables = 'BCC_CR SIGMA_0CR SIGMA_1CR SIGMA_2CR eta1'
  []
  [ACBulkC2]
    type = SLKKSMultiACBulkC
    variable = eta2
    F = F_BCC_A2
    c = BCC_CR
    ns = '1      3'
    as = '1      10        4         16'
    cs = 'BCC_CR SIGMA_0CR SIGMA_1CR SIGMA_2CR'
    h_names = 'h1   h2'
    eta = 'eta1 eta2'
  []
  [ACInterface2]
    type = ACInterface
    variable = eta2
    kappa_name = kappa
  []
  [lagrange2]
    type = SwitchingFunctionConstraintEta
    variable = eta2
    h_name = h2
    lambda = lambda
    coupled_variables = 'eta1'
  []
  # Lagrange-multiplier constraint kernel for lambda
  [lagrange]
    type = SwitchingFunctionConstraintLagrange
    variable = lambda
    h_names = 'h1   h2'
    etas = 'eta1 eta2'
    epsilon = 1e-6
  []
[]
[AuxKernels]
  [GlobalFreeEnergy]
    type = KKSMultiFreeEnergy
    variable = Fglobal
    Fj_names = 'F_BCC_A2 F_SIGMA'
    hj_names = 'h1 h2'
    gj_names = 'g1 g2'
    interfacial_vars = 'eta1 eta2'
    kappa_names = 'kappa kappa'
    w = 0.1
  []
[]
[Executioner]
  type = Transient
  solve_type = 'NEWTON'
  line_search = none
  petsc_options_iname = '-pc_type -sub_pc_type -sub_pc_factor_shift_type -ksp_gmres_restart'
  petsc_options_value = 'asm      lu          nonzero                    30'
  l_max_its = 100
  nl_max_its = 20
  nl_abs_tol = 1e-10
  end_time = 10000
  [TimeStepper]
    type = IterationAdaptiveDT
    optimal_iterations = 12
    iteration_window = 2
    growth_factor = 1.5
    cutback_factor = 0.7
    dt = 0.1
  []
[]
[VectorPostprocessors]
  [var]
    type = LineValueSampler
    start_point = '-25 0 0'
    end_point = '25 0 0'
    variable = 'cCr eta1 eta2 SIGMA_0CR SIGMA_1CR SIGMA_2CR'
    num_points = 151
    sort_by = id
    execute_on = 'initial timestep_end'
  []
  [mat]
    type = LineMaterialRealSampler
    start = '-25 0 0'
    end = '25 0 0'
    property = 'F_BCC_A2 F_SIGMA'
    sort_by = id
    execute_on = 'initial timestep_end'
  []
[]
[Postprocessors]
  [F]
    type = ElementIntegralVariablePostprocessor
    variable = Fglobal
    execute_on = 'initial timestep_end'
  []
  [cmin]
    type = NodalExtremeValue
    value_type = min
    variable = cCr
    execute_on = 'initial timestep_end'
  []
  [cmax]
    type = NodalExtremeValue
    value_type = max
    variable = cCr
    execute_on = 'initial timestep_end'
  []
  [ctotal]
    type = ElementIntegralVariablePostprocessor
    variable = cCr
    execute_on = 'initial timestep_end'
  []
[]
[Outputs]
  exodus = true
  print_linear_residuals = false
  csv = true
  perf_graph = true
[]
(modules/phase_field/test/tests/MultiPhase/lagrangemult.i)
[Mesh]
  type = GeneratedMesh
  dim = 2
  nx = 14
  ny = 10
  nz = 0
  xmin = 10
  xmax = 40
  ymin = 15
  ymax = 35
  elem_type = QUAD4
[]
[Variables]
  [./c]
    order = FIRST
    family = LAGRANGE
    [./InitialCondition]
      type = SmoothCircleIC
      x1 = 25.0
      y1 = 25.0
      radius = 6.0
      invalue = 0.9
      outvalue = 0.1
      int_width = 3.0
    [../]
  [../]
  [./w]
    order = FIRST
    family = LAGRANGE
  [../]
  [./eta1]
    order = FIRST
    family = LAGRANGE
    [./InitialCondition]
      type = SmoothCircleIC
      x1 = 30.0
      y1 = 25.0
      radius = 4.0
      invalue = 0.9
      outvalue = 0.1
      int_width = 2.0
    [../]
  [../]
  [./eta2]
    order = FIRST
    family = LAGRANGE
    initial_condition = 0.5
  [../]
  [./lambda]
    order = FIRST
    family = LAGRANGE
    initial_condition = 1.0
  [../]
[]
[Kernels]
  [./deta1dt]
    type = TimeDerivative
    variable = eta1
  [../]
  [./ACBulk1]
    type = AllenCahn
    variable = eta1
    coupled_variables = 'c eta2'
    f_name = F
  [../]
  [./ACInterface1]
    type = ACInterface
    variable = eta1
    kappa_name = kappa_eta
  [../]
  [./lagrange1]
    type = SwitchingFunctionConstraintEta
    variable = eta1
    h_name   = h1
    lambda = lambda
  [../]
  [./deta2dt]
    type = TimeDerivative
    variable = eta2
  [../]
  [./ACBulk2]
    type = AllenCahn
    variable = eta2
    coupled_variables = 'c eta1'
    f_name = F
  [../]
  [./ACInterface2]
    type = ACInterface
    variable = eta2
    kappa_name = kappa_eta
  [../]
  [./lagrange2]
    type = SwitchingFunctionConstraintEta
    variable = eta2
    h_name   = h2
    lambda = lambda
  [../]
  [./lagrange]
    type = SwitchingFunctionConstraintLagrange
    variable = lambda
    etas    = 'eta1 eta2'
    h_names = 'h1   h2'
    epsilon = 0
  [../]
  [./c_res]
    type = SplitCHParsed
    variable = c
    f_name = F
    kappa_name = kappa_c
    w = w
    coupled_variables = 'eta1 eta2'
  [../]
  [./w_res]
    type = SplitCHWRes
    variable = w
    mob_name = M
  [../]
  [./time1]
    type = CoupledTimeDerivative
    variable = w
    v = c
  [../]
[]
[BCs]
  [./Periodic]
    [./All]
      auto_direction = 'x y'
    [../]
  [../]
[]
[Materials]
  [./consts]
    type = GenericConstantMaterial
    prop_names  = 'L kappa_eta'
    prop_values = '1 1        '
  [../]
  [./consts2]
    type = GenericConstantMaterial
    prop_names  = 'M kappa_c'
    prop_values = '1 1'
  [../]
  [./switching1]
    type = SwitchingFunctionMaterial
    function_name = h1
    eta = eta1
    h_order = SIMPLE
    outputs = exodus
  [../]
  [./switching2]
    type = SwitchingFunctionMaterial
    function_name = h2
    eta = eta2
    h_order = SIMPLE
    outputs = exodus
  [../]
  [./barrier]
    type = MultiBarrierFunctionMaterial
    etas = 'eta1 eta2'
  [../]
  [./free_energy_A]
    type = DerivativeParsedMaterial
    property_name = Fa
    coupled_variables = 'c'
    expression = '(c-0.1)^2'
    derivative_order = 2
    enable_jit = true
  [../]
  [./free_energy_B]
    type = DerivativeParsedMaterial
    property_name = Fb
    coupled_variables = 'c'
    expression = '(c-0.9)^2'
    derivative_order = 2
    enable_jit = true
  [../]
  [./free_energy]
    type = DerivativeMultiPhaseMaterial
    property_name = F
    fi_names = 'Fa   Fb'
    hi_names = 'h1   h2'
    etas     = 'eta1 eta2'
    coupled_variables = 'c'
    derivative_order = 2
  [../]
[]
[Preconditioning]
  [./SMP]
    type = SMP
    full = true
  [../]
[]
[Executioner]
  type = Transient
  scheme = 'bdf2'
  solve_type = 'PJFNK'
  #petsc_options = '-snes_ksp -snes_ksp_ew'
  #petsc_options = '-ksp_monitor_snes_lg-snes_ksp_ew'
  #petsc_options_iname = '-ksp_gmres_restart'
  #petsc_options_value = '1000              '
  l_max_its = 15
  l_tol = 1.0e-6
  nl_max_its = 50
  nl_rel_tol = 1.0e-8
  nl_abs_tol = 1.0e-10
  start_time = 0.0
  num_steps = 1
  dt = 0.01
  dtmin = 0.01
[]
[Debug]
  # show_var_residual_norms = true
[]
[Outputs]
  execute_on = 'timestep_end'
  exodus = true
[]
(modules/phase_field/test/tests/KKS_system/kks_example_multiphase_nested_damped.i)
#
# This test is for the damped nested solve of 3-phase KKS model, and uses log-based free energies.
# The split-form of the Cahn-Hilliard equation instead of the Fick's diffusion equation is solved
[Mesh]
  type = GeneratedMesh
  dim = 2
  nx = 20
  ny = 20
  nz = 0
  xmin = 0
  xmax = 40
  ymin = 0
  ymax = 40
  zmin = 0
  zmax = 0
  elem_type = QUAD4
[]
[BCs]
  [Periodic]
    [all]
      auto_direction = 'x y'
    []
  []
[]
[AuxVariables]
  [Energy]
    order = CONSTANT
    family = MONOMIAL
  []
[]
[Variables]
  # concentration
  [c]
    order = FIRST
    family = LAGRANGE
  []
  # order parameter 1
  [eta1]
    order = FIRST
    family = LAGRANGE
  []
  # order parameter 2
  [eta2]
    order = FIRST
    family = LAGRANGE
  []
  # order parameter 3
  [eta3]
    order = FIRST
    family = LAGRANGE
    initial_condition = 0.0
  []
  # chemical potential
  [mu]
    order = FIRST
    family = LAGRANGE
    initial_condition = 0.0
  []
  # Lagrange multiplier
  [lambda]
    order = FIRST
    family = LAGRANGE
    initial_condition = 0.0
  []
[]
[ICs]
  [eta1]
    variable = eta1
    type = SmoothCircleIC
    x1 = 20.0
    y1 = 20.0
    radius = 10
    invalue = 0.9
    outvalue = 0.1
    int_width = 4
  []
  [eta2]
    variable = eta2
    type = SmoothCircleIC
    x1 = 20.0
    y1 = 20.0
    radius = 10
    invalue = 0.1
    outvalue = 0.9
    int_width = 4
  []
  [c]
    variable = c
    type = SmoothCircleIC
    x1 = 20.0
    y1 = 20.0
    radius = 10
    invalue = 0.2
    outvalue = 0.5
    int_width = 2
  []
[]
[Materials]
  # simple toy free energies
  [F1]
    type = DerivativeParsedMaterial
    property_name = F1
    expression = 'c1*log(c1/1e-4) + (1-c1)*log((1-c1)/(1-1e-4))'
    material_property_names = 'c1'
    additional_derivative_symbols = 'c1'
    compute = false
  []
  [F2]
    type = DerivativeParsedMaterial
    property_name = F2
    expression = 'c2*log(c2/0.5) + (1-c2)*log((1-c2)/(1-0.5))'
    material_property_names = 'c2'
    additional_derivative_symbols = 'c2'
    compute = false
  []
  [F3]
    type = DerivativeParsedMaterial
    property_name = F3
    expression = 'c3*log(c3/0.9999) + (1-c3)*log((1-c3)/(1-0.9999))'
    material_property_names = 'c3'
    additional_derivative_symbols = 'c3'
    compute = false
  []
  [C]
    type = DerivativeParsedMaterial
    property_name = 'C'
    material_property_names = 'c1 c2 c3'
    expression = '(c1>0)&(c1<1)&(c2>0)&(c2<1)&(c3>0)&(c3<1)'
    compute = false
  []
  [KKSPhaseConcentrationMultiPhaseMaterial]
    type = KKSPhaseConcentrationMultiPhaseMaterial
    global_cs = 'c'
    all_etas = 'eta1 eta2 eta3'
    hj_names = 'h1 h2 h3'
    ci_names = 'c1 c2 c3'
    ci_IC = '0.2 0.5 0.8'
    Fj_names = 'F1 F2 F3'
    min_iterations = 1
    max_iterations = 1000
    absolute_tolerance = 1e-15
    relative_tolerance = 1e-8
    step_size_tolerance = 1e-05
    damped_Newton = true
    conditions = C
    damping_factor = 0.8
  []
  [KKSPhaseConcentrationMultiPhaseDerivatives]
    type = KKSPhaseConcentrationMultiPhaseDerivatives
    global_cs = 'c'
    all_etas = 'eta1 eta2 eta3'
    Fj_names = 'F1 F2 F3'
    hj_names = 'h1 h2 h3'
    ci_names = 'c1 c2 c3'
  []
  # Switching functions for each phase
  # h1(eta1, eta2, eta3)
  [h1]
    type = SwitchingFunction3PhaseMaterial
    eta_i = eta1
    eta_j = eta2
    eta_k = eta3
    property_name = h1
  []
  # h2(eta1, eta2, eta3)
  [h2]
    type = SwitchingFunction3PhaseMaterial
    eta_i = eta2
    eta_j = eta3
    eta_k = eta1
    property_name = h2
  []
  # h3(eta1, eta2, eta3)
  [h3]
    type = SwitchingFunction3PhaseMaterial
    eta_i = eta3
    eta_j = eta1
    eta_k = eta2
    property_name = h3
  []
  # Barrier functions for each phase
  [g1]
    type = BarrierFunctionMaterial
    g_order = SIMPLE
    eta = eta1
    function_name = g1
  []
  [g2]
    type = BarrierFunctionMaterial
    g_order = SIMPLE
    eta = eta2
    function_name = g2
  []
  [g3]
    type = BarrierFunctionMaterial
    g_order = SIMPLE
    eta = eta3
    function_name = g3
  []
  # constant properties
  [constants]
    type = GenericConstantMaterial
    prop_names = 'L   kappa  M'
    prop_values = '0.7 1.0    0.025'
  []
[]
[Kernels]
  [lambda_lagrange]
    type = SwitchingFunctionConstraintLagrange
    variable = lambda
    etas = 'eta1 eta2 eta3'
    h_names = 'h1   h2   h3'
    epsilon = 1e-04
  []
  [eta1_lagrange]
    type = SwitchingFunctionConstraintEta
    variable = eta1
    h_name = h1
    lambda = lambda
    coupled_variables = 'eta2 eta3'
  []
  [eta2_lagrange]
    type = SwitchingFunctionConstraintEta
    variable = eta2
    h_name = h2
    lambda = lambda
    coupled_variables = 'eta1 eta3'
  []
  [eta3_lagrange]
    type = SwitchingFunctionConstraintEta
    variable = eta3
    h_name = h3
    lambda = lambda
    coupled_variables = 'eta1 eta2'
  []
  #Kernels for Cahn-Hilliard equation
  [diff_time]
    type = CoupledTimeDerivative
    variable = mu
    v = c
  []
  [CHBulk]
    type = NestedKKSMultiSplitCHCRes
    variable = c
    all_etas = 'eta1 eta2 eta3'
    global_cs = 'c'
    w = mu
    c1_names = 'c1'
    F1_name = F1
    coupled_variables = 'eta1 eta2 eta3 mu'
  []
  [ckernel]
    type = SplitCHWRes
    variable = mu
    mob_name = M
  []
  # Kernels for Allen-Cahn equation for eta1
  [deta1dt]
    type = TimeDerivative
    variable = eta1
  []
  [ACBulkF1]
    type = NestedKKSMultiACBulkF
    variable = eta1
    global_cs = 'c'
    eta_i = eta1
    all_etas = 'eta1 eta2 eta3'
    ci_names = 'c1 c2 c3'
    hj_names = 'h1 h2 h3'
    Fj_names = 'F1 F2 F3'
    gi_name = g1
    mob_name = L
    wi = 1.0
    coupled_variables = 'c eta2 eta3'
  []
  [ACBulkC1]
    type = NestedKKSMultiACBulkC
    variable = eta1
    global_cs = 'c'
    eta_i = eta1
    all_etas = 'eta1 eta2 eta3'
    ci_names = 'c1 c2 c3'
    hj_names = 'h1 h2 h3'
    Fj_names = 'F1 F2 F3'
    coupled_variables = 'c eta2 eta3'
  []
  [ACInterface1]
    type = ACInterface
    variable = eta1
    kappa_name = kappa
  []
  # Kernels for Allen-Cahn equation for eta2
  [deta2dt]
    type = TimeDerivative
    variable = eta2
  []
  [ACBulkF2]
    type = NestedKKSMultiACBulkF
    variable = eta2
    global_cs = 'c'
    eta_i = eta2
    all_etas = 'eta1 eta2 eta3'
    ci_names = 'c1 c2 c3'
    hj_names = 'h1 h2 h3'
    Fj_names = 'F1 F2 F3'
    gi_name = g2
    mob_name = L
    wi = 1.0
    coupled_variables = 'c eta1 eta3'
  []
  [ACBulkC2]
    type = NestedKKSMultiACBulkC
    variable = eta2
    global_cs = 'c'
    eta_i = eta2
    all_etas = 'eta1 eta2 eta3'
    ci_names = 'c1 c2 c3'
    hj_names = 'h1 h2 h3'
    Fj_names = 'F1 F2 F3'
    coupled_variables = 'c eta1 eta3'
  []
  [ACInterface2]
    type = ACInterface
    variable = eta2
    kappa_name = kappa
  []
  # Kernels for Allen-Cahn equation for eta3
  [deta3dt]
    type = TimeDerivative
    variable = eta3
  []
  [ACBulkF3]
    type = NestedKKSMultiACBulkF
    variable = eta3
    global_cs = 'c'
    eta_i = eta3
    all_etas = 'eta1 eta2 eta3'
    ci_names = 'c1 c2 c3'
    hj_names = 'h1 h2 h3'
    Fj_names = 'F1 F2 F3'
    gi_name = g3
    mob_name = L
    wi = 1.0
    coupled_variables = 'c eta1 eta2'
  []
  [ACBulkC3]
    type = NestedKKSMultiACBulkC
    variable = eta3
    global_cs = 'c'
    eta_i = eta3
    all_etas = 'eta1 eta2 eta3'
    ci_names = 'c1 c2 c3'
    hj_names = 'h1 h2 h3'
    Fj_names = 'F1 F2 F3'
    coupled_variables = 'c eta1 eta2'
  []
  [ACInterface3]
    type = ACInterface
    variable = eta3
    kappa_name = kappa
  []
[]
[AuxKernels]
  [Energy_total]
    type = KKSMultiFreeEnergy
    Fj_names = 'F1 F2 F3'
    hj_names = 'h1 h2 h3'
    gj_names = 'g1 g2 g3'
    variable = Energy
    w = 1
    interfacial_vars = 'eta1  eta2  eta3'
    kappa_names = 'kappa kappa kappa'
  []
[]
[Executioner]
  type = Transient
  solve_type = 'PJFNK'
  petsc_options_iname = '-pc_type -sub_pc_type   -sub_pc_factor_shift_type'
  petsc_options_value = 'asm       ilu            nonzero'
  l_max_its = 30
  nl_max_its = 10
  l_tol = 1.0e-4
  nl_rel_tol = 1.0e-10
  nl_abs_tol = 1.0e-11
  num_steps = 2
  dt = 0.01
[]
[Preconditioning]
  active = 'full'
  [full]
    type = SMP
    full = true
  []
  [mydebug]
    type = FDP
    full = true
  []
[]
[Outputs]
  file_base = kks_example_multiphase_nested_damped
  exodus = true
[]
(modules/combined/examples/publications/rapid_dev/fig8.i)
#
# Fig. 8 input for 10.1016/j.commatsci.2017.02.017
# D. Schwen et al./Computational Materials Science 132 (2017) 36-45
# Two growing particles with differnet anisotropic Eigenstrains
#
[Mesh]
  [./gen]
    type = GeneratedMeshGenerator
    dim = 2
    nx = 80
    ny = 40
    xmin = -20
    xmax = 20
    ymin = 0
    ymax = 20
    elem_type = QUAD4
  [../]
  [./cnode]
    type = ExtraNodesetGenerator
    input = gen
    coord = '0.0 0.0'
    new_boundary = 100
    tolerance = 0.1
  [../]
[]
[GlobalParams]
  # CahnHilliard needs the third derivatives
  derivative_order = 3
  enable_jit = true
  displacements = 'disp_x disp_y'
  int_width = 1
[]
# AuxVars to compute the free energy density for outputting
[AuxVariables]
  [./local_energy]
    order = CONSTANT
    family = MONOMIAL
  [../]
  [./cross_energy]
    order = CONSTANT
    family = MONOMIAL
  [../]
[]
[AuxKernels]
  [./local_free_energy]
    type = TotalFreeEnergy
    variable = local_energy
    interfacial_vars = 'c'
    kappa_names = 'kappa_c'
    additional_free_energy = cross_energy
    execute_on = 'INITIAL TIMESTEP_END'
  [../]
  [./cross_terms]
    type = CrossTermGradientFreeEnergy
    variable = cross_energy
    interfacial_vars = 'eta1 eta2 eta3'
    kappa_names = 'kappa11 kappa12 kappa13
                   kappa21 kappa22 kappa23
                   kappa31 kappa32 kappa33'
    execute_on = 'INITIAL TIMESTEP_END'
  [../]
[]
# particle x positions and radius
P1X=8
P2X=-4
PR=2
[Variables]
  # Solute concentration variable
  [./c]
    [./InitialCondition]
      type = SpecifiedSmoothCircleIC
      x_positions = '${P1X} ${P2X}'
      y_positions = '0 0'
      z_positions = '0 0'
      radii = '${PR} ${PR}'
      outvalue = 0.5
      invalue = 0.9
    [../]
  [../]
  [./w]
  [../]
  # Order parameter for the Matrix
  [./eta1]
    [./InitialCondition]
      type = SpecifiedSmoothCircleIC
      x_positions = '${P1X} ${P2X}'
      y_positions = '0 0'
      z_positions = '0 0'
      radii = '${PR} ${PR}'
      outvalue = 1.0
      invalue = 0.0
    [../]
  [../]
  # Order parameters for the 2 different inclusion orientations
  [./eta2]
    [./InitialCondition]
      type = SmoothCircleIC
      x1 = ${P2X}
      y1 = 0
      radius = ${PR}
      invalue = 1.0
      outvalue = 0.0
    [../]
  [../]
  [./eta3]
    [./InitialCondition]
      type = SmoothCircleIC
      x1 = ${P1X}
      y1 = 0
      radius = ${PR}
      invalue = 1.0
      outvalue = 0.0
    [../]
  [../]
  # Lagrange-multiplier
  [./lambda]
    initial_condition = 1.0
  [../]
[]
[Physics/SolidMechanics/QuasiStatic/all]
  add_variables = true
  strain = SMALL
  eigenstrain_names = eigenstrain
[]
[Kernels]
  # Split Cahn-Hilliard kernels
  [./c_res]
    type = SplitCHParsed
    variable = c
    f_name = F
    coupled_variables = 'eta1 eta2 eta3'
    kappa_name = kappa_c
    w = w
  [../]
  [./wres]
    type = SplitCHWRes
    variable = w
    mob_name = M
  [../]
  [./time]
    type = CoupledTimeDerivative
    variable = w
    v = c
  [../]
  # Allen-Cahn and Lagrange-multiplier constraint kernels for order parameter 1
  [./deta1dt]
    type = TimeDerivative
    variable = eta1
  [../]
  [./ACBulk1]
    type = AllenCahn
    variable = eta1
    coupled_variables = 'eta2 eta3 c'
    mob_name = L1
    f_name = F
  [../]
  [./ACInterface1]
    type = ACMultiInterface
    variable = eta1
    etas = 'eta1 eta2 eta3'
    mob_name = L1
    kappa_names = 'kappa11 kappa12 kappa13'
  [../]
  [./lagrange1]
    type = SwitchingFunctionConstraintEta
    variable = eta1
    h_name   = h1
    lambda = lambda
  [../]
  # Allen-Cahn and Lagrange-multiplier constraint kernels for order parameter 2
  [./deta2dt]
    type = TimeDerivative
    variable = eta2
  [../]
  [./ACBulk2]
    type = AllenCahn
    variable = eta2
    coupled_variables = 'eta1 eta3 c'
    mob_name = L2
    f_name = F
  [../]
  [./ACInterface2]
    type = ACMultiInterface
    variable = eta2
    etas = 'eta1 eta2 eta3'
    mob_name = L2
    kappa_names = 'kappa21 kappa22 kappa23'
  [../]
  [./lagrange2]
    type = SwitchingFunctionConstraintEta
    variable = eta2
    h_name   = h2
    lambda = lambda
  [../]
  # Allen-Cahn and Lagrange-multiplier constraint kernels for order parameter 3
  [./deta3dt]
    type = TimeDerivative
    variable = eta3
  [../]
  [./ACBulk3]
    type = AllenCahn
    variable = eta3
    coupled_variables = 'eta1 eta2 c'
    mob_name = L3
    f_name = F
  [../]
  [./ACInterface3]
    type = ACMultiInterface
    variable = eta3
    etas = 'eta1 eta2 eta3'
    mob_name = L3
    kappa_names = 'kappa31 kappa32 kappa33'
  [../]
  [./lagrange3]
    type = SwitchingFunctionConstraintEta
    variable = eta3
    h_name   = h3
    lambda = lambda
  [../]
  # Lagrange-multiplier constraint kernel for lambda
  [./lagrange]
    type = SwitchingFunctionConstraintLagrange
    variable = lambda
    etas    = 'eta1 eta2 eta3'
    h_names = 'h1   h2   h3'
    epsilon = 1e-6
  [../]
[]
[Materials]
  # declare a few constants, such as mobilities (L,M) and interface gradient prefactors (kappa*)
  [./consts]
    type = GenericConstantMaterial
    block = 0
    prop_names  = 'M   kappa_c  L1 L2 L3  kappa11 kappa12 kappa13 kappa21 kappa22 kappa23 kappa31 kappa32 kappa33'
    prop_values = '0.2 0.5      1  1  1   2.00    2.00    2.00    2.00    2.00    2.00    2.00    2.00    2.00   '
  [../]
  # We use this to output the level of constraint enforcement
  # ideally it should be 0 everywhere, if the constraint is fully enforced
  [./etasummat]
    type = ParsedMaterial
    property_name = etasum
    coupled_variables = 'eta1 eta2 eta3'
    material_property_names = 'h1 h2 h3'
    expression = 'h1+h2+h3-1'
    outputs = exodus
  [../]
  # This parsed material creates a single property for visualization purposes.
  # It will be 0 for phase 1, -1 for phase 2, and 1 for phase 3
  [./phasemap]
    type = ParsedMaterial
    property_name = phase
    coupled_variables = 'eta2 eta3'
    expression = 'if(eta3>0.5,1,0)-if(eta2>0.5,1,0)'
    outputs = exodus
  [../]
  # global mechanical properties
  [./elasticity_tensor]
    type = ComputeElasticityTensor
    C_ijkl = '400 400'
    fill_method = symmetric_isotropic
  [../]
  [./stress]
    type = ComputeLinearElasticStress
  [../]
  # eigenstrain
  [./eigenstrain_2]
    type = GenericConstantRankTwoTensor
    tensor_name = s2
    tensor_values = '0 -0.05 0  0 0 0'
  [../]
  [./eigenstrain_3]
    type = GenericConstantRankTwoTensor
    tensor_name = s3
    tensor_values =  '-0.05 0 0  0 0 0'
  [../]
  [./eigenstrain]
    type = CompositeEigenstrain
    weights = 'h2 h3'
    tensors = 's2 s3'
    coupled_variables = 'eta2 eta3'
    eigenstrain_name = eigenstrain
  [../]
  # switching functions
  [./switching1]
    type = SwitchingFunctionMaterial
    function_name = h1
    eta = eta1
    h_order = SIMPLE
  [../]
  [./switching2]
    type = SwitchingFunctionMaterial
    function_name = h2
    eta = eta2
    h_order = SIMPLE
  [../]
  [./switching3]
    type = SwitchingFunctionMaterial
    function_name = h3
    eta = eta3
    h_order = SIMPLE
  [../]
  [./barrier]
    type = MultiBarrierFunctionMaterial
    etas = 'eta1 eta2 eta3'
  [../]
  # chemical free energies
  [./chemical_free_energy_1]
    type = DerivativeParsedMaterial
    property_name = Fc1
    expression = '4*c^2'
    coupled_variables = 'c'
    derivative_order = 2
  [../]
  [./chemical_free_energy_2]
    type = DerivativeParsedMaterial
    property_name = Fc2
    expression = '(c-0.9)^2-0.4'
    coupled_variables = 'c'
    derivative_order = 2
  [../]
  [./chemical_free_energy_3]
    type = DerivativeParsedMaterial
    property_name = Fc3
    expression = '(c-0.9)^2-0.5'
    coupled_variables = 'c'
    derivative_order = 2
  [../]
  # global chemical free energy
  [./chemical_free_energy]
    type = DerivativeMultiPhaseMaterial
    f_name = Fc
    fi_names = 'Fc1  Fc2  Fc3'
    hi_names = 'h1  h2  h3'
    etas     = 'eta1 eta2 eta3'
    coupled_variables = 'c'
    W = 3
  [../]
  # global elastic free energy
  [./elastic_free_energy]
    type = ElasticEnergyMaterial
    f_name = Fe
    coupled_variables = 'eta2 eta3'
    outputs = exodus
    output_properties = Fe
    derivative_order = 2
  [../]
  # Penalize phase 2 and 3 coexistence
  [./multi_phase_penalty]
    type = DerivativeParsedMaterial
    property_name = Fp
    expression = '50*(eta2*eta3)^2'
    coupled_variables = 'eta2 eta3'
    derivative_order = 2
    outputs = exodus
    output_properties = Fp
  [../]
  # free energy
  [./free_energy]
    type = DerivativeSumMaterial
    property_name = F
    sum_materials = 'Fc Fe Fp'
    coupled_variables = 'c eta1 eta2 eta3'
    derivative_order = 2
  [../]
[]
[BCs]
  # fix center point location
  [./centerfix_x]
    type = DirichletBC
    boundary = 100
    variable = disp_x
    value = 0
  [../]
  # fix side point x coordinate to inhibit rotation
  [./angularfix]
    type = DirichletBC
    boundary = bottom
    variable = disp_y
    value = 0
  [../]
[]
[Preconditioning]
  [./SMP]
    type = SMP
    full = true
  [../]
[]
# We monitor the total free energy and the total solute concentration (should be constant)
[Postprocessors]
  [./total_free_energy]
    type = ElementIntegralVariablePostprocessor
    variable = local_energy
    execute_on = 'INITIAL TIMESTEP_END'
  [../]
  [./total_solute]
    type = ElementIntegralVariablePostprocessor
    variable = c
    execute_on = 'INITIAL TIMESTEP_END'
  [../]
[]
[Executioner]
  type = Transient
  scheme = bdf2
  solve_type = 'PJFNK'
  petsc_options_iname = '-pc_type -sub_pc_type'
  petsc_options_value = 'asm      lu'
  l_max_its = 30
  nl_max_its = 10
  l_tol = 1.0e-4
  nl_rel_tol = 1.0e-8
  nl_abs_tol = 1.0e-10
  start_time = 0.0
  end_time = 12.0
  [./TimeStepper]
    type = IterationAdaptiveDT
    optimal_iterations = 8
    iteration_window = 1
    dt = 0.01
  [../]
[]
[Outputs]
  print_linear_residuals = false
  execute_on = 'INITIAL TIMESTEP_END'
  exodus = true
  [./table]
    type = CSV
    delimiter = ' '
  [../]
[]
[Debug]
  # show_var_residual_norms = true
[]
(modules/phase_field/test/tests/KKS_system/kks_example_multiphase_nested.i)
#
# This test is for the nested solve of 3-phase KKS model
# The split-form of the Cahn-Hilliard equation instead of the Fick's diffusion equation is solved
[Mesh]
  type = GeneratedMesh
  dim = 2
  nx = 20
  ny = 20
  nz = 0
  xmin = 0
  xmax = 40
  ymin = 0
  ymax = 40
  zmin = 0
  zmax = 0
  elem_type = QUAD4
[]
[BCs]
  [Periodic]
    [all]
      auto_direction = 'x y'
    []
  []
[]
[AuxVariables]
  [Energy]
    order = CONSTANT
    family = MONOMIAL
  []
[]
[Variables]
  # concentration
  [c]
    order = FIRST
    family = LAGRANGE
  []
  # order parameter 1
  [eta1]
    order = FIRST
    family = LAGRANGE
  []
  # order parameter 2
  [eta2]
    order = FIRST
    family = LAGRANGE
  []
  # order parameter 3
  [eta3]
    order = FIRST
    family = LAGRANGE
    initial_condition = 0.0
  []
  # chemical potential
  [mu]
    order = FIRST
    family = LAGRANGE
    initial_condition = 0.0
  []
  # Lagrange multiplier
  [lambda]
    order = FIRST
    family = LAGRANGE
    initial_condition = 0.0
  []
[]
[ICs]
  [eta1]
    variable = eta1
    type = SmoothCircleIC
    x1 = 20.0
    y1 = 20.0
    radius = 10
    invalue = 0.9
    outvalue = 0.1
    int_width = 4
  []
  [eta2]
    variable = eta2
    type = SmoothCircleIC
    x1 = 20.0
    y1 = 20.0
    radius = 10
    invalue = 0.1
    outvalue = 0.9
    int_width = 4
  []
  [c]
    variable = c
    type = SmoothCircleIC
    x1 = 20.0
    y1 = 20.0
    radius = 10
    invalue = 0.2
    outvalue = 0.5
    int_width = 2
  []
[]
[Materials]
  # simple toy free energies
  [F1]
    type = DerivativeParsedMaterial
    property_name = F1
    expression = '20*(c1-0.2)^2'
    material_property_names = 'c1'
    additional_derivative_symbols = 'c1'
    compute = false
  []
  [F2]
    type = DerivativeParsedMaterial
    property_name = F2
    expression = '20*(c2-0.5)^2'
    material_property_names = 'c2'
    additional_derivative_symbols = 'c2'
    compute = false
  []
  [F3]
    type = DerivativeParsedMaterial
    property_name = F3
    expression = '20*(c3-0.8)^2'
    material_property_names = 'c3'
    additional_derivative_symbols = 'c3'
    compute = false
  []
  [KKSPhaseConcentrationMultiPhaseMaterial]
    type = KKSPhaseConcentrationMultiPhaseMaterial
    global_cs = 'c'
    all_etas = 'eta1 eta2 eta3'
    hj_names = 'h1 h2 h3'
    ci_names = 'c1 c2 c3'
    ci_IC = '0.2 0.5 0.8'
    Fj_names = 'F1 F2 F3'
    min_iterations = 1
    max_iterations = 1000
    absolute_tolerance = 1e-11
    relative_tolerance = 1e-10
  []
  [KKSPhaseConcentrationMultiPhaseDerivatives]
    type = KKSPhaseConcentrationMultiPhaseDerivatives
    global_cs = 'c'
    all_etas = 'eta1 eta2 eta3'
    Fj_names = 'F1 F2 F3'
    hj_names = 'h1 h2 h3'
    ci_names = 'c1 c2 c3'
  []
  # Switching functions for each phase
  # h1(eta1, eta2, eta3)
  [h1]
    type = SwitchingFunction3PhaseMaterial
    eta_i = eta1
    eta_j = eta2
    eta_k = eta3
    property_name = h1
  []
  # h2(eta1, eta2, eta3)
  [h2]
    type = SwitchingFunction3PhaseMaterial
    eta_i = eta2
    eta_j = eta3
    eta_k = eta1
    property_name = h2
  []
  # h3(eta1, eta2, eta3)
  [h3]
    type = SwitchingFunction3PhaseMaterial
    eta_i = eta3
    eta_j = eta1
    eta_k = eta2
    property_name = h3
  []
  # Barrier functions for each phase
  [g1]
    type = BarrierFunctionMaterial
    g_order = SIMPLE
    eta = eta1
    function_name = g1
  []
  [g2]
    type = BarrierFunctionMaterial
    g_order = SIMPLE
    eta = eta2
    function_name = g2
  []
  [g3]
    type = BarrierFunctionMaterial
    g_order = SIMPLE
    eta = eta3
    function_name = g3
  []
  # constant properties
  [constants]
    type = GenericConstantMaterial
    prop_names = 'L   kappa  M'
    prop_values = '0.7 1.0    0.025'
  []
[]
[Kernels]
  [lambda_lagrange]
    type = SwitchingFunctionConstraintLagrange
    variable = lambda
    etas = 'eta1 eta2 eta3'
    h_names = 'h1   h2   h3'
    epsilon = 1e-04
  []
  [eta1_lagrange]
    type = SwitchingFunctionConstraintEta
    variable = eta1
    h_name = h1
    lambda = lambda
    coupled_variables = 'eta2 eta3'
  []
  [eta2_lagrange]
    type = SwitchingFunctionConstraintEta
    variable = eta2
    h_name = h2
    lambda = lambda
    coupled_variables = 'eta1 eta3'
  []
  [eta3_lagrange]
    type = SwitchingFunctionConstraintEta
    variable = eta3
    h_name = h3
    lambda = lambda
    coupled_variables = 'eta1 eta2'
  []
  #Kernels for Cahn-Hilliard equation
  [diff_time]
    type = CoupledTimeDerivative
    variable = mu
    v = c
  []
  [CHBulk]
    type = NestedKKSMultiSplitCHCRes
    variable = c
    all_etas = 'eta1 eta2 eta3'
    global_cs = 'c'
    w = mu
    c1_names = 'c1'
    F1_name = F1
    coupled_variables = 'eta1 eta2 eta3 mu'
  []
  [ckernel]
    type = SplitCHWRes
    variable = mu
    mob_name = M
  []
  # Kernels for Allen-Cahn equation for eta1
  [deta1dt]
    type = TimeDerivative
    variable = eta1
  []
  [ACBulkF1]
    type = NestedKKSMultiACBulkF
    variable = eta1
    global_cs = 'c'
    eta_i = eta1
    all_etas = 'eta1 eta2 eta3'
    ci_names = 'c1 c2 c3'
    hj_names = 'h1 h2 h3'
    Fj_names = 'F1 F2 F3'
    gi_name = g1
    mob_name = L
    wi = 1.0
    coupled_variables = 'c eta2 eta3'
  []
  [ACBulkC1]
    type = NestedKKSMultiACBulkC
    variable = eta1
    global_cs = 'c'
    eta_i = eta1
    all_etas = 'eta1 eta2 eta3'
    ci_names = 'c1 c2 c3'
    hj_names = 'h1 h2 h3'
    Fj_names = 'F1 F2 F3'
    coupled_variables = 'c eta2 eta3'
  []
  [ACInterface1]
    type = ACInterface
    variable = eta1
    kappa_name = kappa
  []
  # Kernels for Allen-Cahn equation for eta2
  [deta2dt]
    type = TimeDerivative
    variable = eta2
  []
  [ACBulkF2]
    type = NestedKKSMultiACBulkF
    variable = eta2
    global_cs = 'c'
    eta_i = eta2
    all_etas = 'eta1 eta2 eta3'
    ci_names = 'c1 c2 c3'
    hj_names = 'h1 h2 h3'
    Fj_names = 'F1 F2 F3'
    gi_name = g2
    mob_name = L
    wi = 1.0
    coupled_variables = 'c eta1 eta3'
  []
  [ACBulkC2]
    type = NestedKKSMultiACBulkC
    variable = eta2
    global_cs = 'c'
    eta_i = eta2
    all_etas = 'eta1 eta2 eta3'
    ci_names = 'c1 c2 c3'
    hj_names = 'h1 h2 h3'
    Fj_names = 'F1 F2 F3'
    coupled_variables = 'c eta1 eta3'
  []
  [ACInterface2]
    type = ACInterface
    variable = eta2
    kappa_name = kappa
  []
  # Kernels for Allen-Cahn equation for eta3
  [deta3dt]
    type = TimeDerivative
    variable = eta3
  []
  [ACBulkF3]
    type = NestedKKSMultiACBulkF
    variable = eta3
    global_cs = 'c'
    eta_i = eta3
    all_etas = 'eta1 eta2 eta3'
    ci_names = 'c1 c2 c3'
    hj_names = 'h1 h2 h3'
    Fj_names = 'F1 F2 F3'
    gi_name = g3
    mob_name = L
    wi = 1.0
    coupled_variables = 'c eta1 eta2'
  []
  [ACBulkC3]
    type = NestedKKSMultiACBulkC
    variable = eta3
    global_cs = 'c'
    eta_i = eta3
    all_etas = 'eta1 eta2 eta3'
    ci_names = 'c1 c2 c3'
    hj_names = 'h1 h2 h3'
    Fj_names = 'F1 F2 F3'
    coupled_variables = 'c eta1 eta2'
  []
  [ACInterface3]
    type = ACInterface
    variable = eta3
    kappa_name = kappa
  []
[]
[AuxKernels]
  [Energy_total]
    type = KKSMultiFreeEnergy
    Fj_names = 'F1 F2 F3'
    hj_names = 'h1 h2 h3'
    gj_names = 'g1 g2 g3'
    variable = Energy
    w = 1
    interfacial_vars = 'eta1  eta2  eta3'
    kappa_names = 'kappa kappa kappa'
  []
[]
[Executioner]
  type = Transient
  solve_type = 'PJFNK'
  petsc_options_iname = '-pc_type -sub_pc_type   -sub_pc_factor_shift_type'
  petsc_options_value = 'asm       ilu            nonzero'
  l_max_its = 30
  nl_max_its = 10
  l_tol = 1.0e-4
  nl_rel_tol = 1.0e-10
  nl_abs_tol = 1.0e-11
  num_steps = 2
  dt = 0.5
[]
[Preconditioning]
  active = 'full'
  [full]
    type = SMP
    full = true
  []
  [mydebug]
    type = FDP
    full = true
  []
[]
[Outputs]
  file_base = kks_example_multiphase_nested
  exodus = true
[]
(modules/phase_field/test/tests/slkks/full_solve.i)
#
# SLKKS two phase example for the BCC and SIGMA phases. The sigma phase contains
# multiple sublattices. Free energy from
# Jacob, Aurelie, Erwin Povoden-Karadeniz, and Ernst Kozeschnik. "Revised thermodynamic
# description of the Fe-Cr system based on an improved sublattice model of the sigma phase."
# Calphad 60 (2018): 16-28.
#
# In this simulation we consider diffusion (Cahn-Hilliard) and phase transformation.
#
[Mesh]
  [gen]
    type = GeneratedMeshGenerator
    dim = 1
    nx = 30
    ny = 1
    xmin = -25
    xmax = 25
  []
[]
[AuxVariables]
  [Fglobal]
    order = CONSTANT
    family = MONOMIAL
  []
[]
[Variables]
  # order parameters
  [eta1]
    initial_condition = 0.5
  []
  [eta2]
    initial_condition = 0.5
  []
  # solute concentration
  [cCr]
    order = FIRST
    family = LAGRANGE
    [InitialCondition]
      type = FunctionIC
      function = '(x+25)/50*0.5+0.1'
    []
  []
  # sublattice concentrations (good guesses are needed here! - they can be obtained
  # form a static solve like in sublattice_concentrations.i)
  [BCC_CR]
    [InitialCondition]
      type = FunctionIC
      function = '(x+25)/50*0.5+0.1'
    []
  []
  [SIGMA_0CR]
    [InitialCondition]
      type = FunctionIC
      function = '(x+25)/50*0.17+0.01'
    []
  []
  [SIGMA_1CR]
    [InitialCondition]
      type = FunctionIC
      function = '(x+25)/50*0.36+0.02'
    []
  []
  [SIGMA_2CR]
    [InitialCondition]
      type = FunctionIC
      function = '(x+25)/50*0.33+0.20'
    []
  []
  # Lagrange multiplier
  [lambda]
  []
[]
[Materials]
  # CALPHAD free energies
  [F_BCC_A2]
    type = DerivativeParsedMaterial
    property_name = F_BCC_A2
    outputs = exodus
    output_properties = F_BCC_A2
    expression = 'BCC_FE:=1-BCC_CR; G := 8.3145*T*(1.0*if(BCC_CR > 1.0e-15,BCC_CR*log(BCC_CR),0) + '
               '1.0*if(BCC_FE > 1.0e-15,BCC_FE*plog(BCC_FE,eps),0) + 3.0*if(BCC_VA > '
               '1.0e-15,BCC_VA*log(BCC_VA),0))/(BCC_CR + BCC_FE) + 8.3145*T*if(T < '
               '548.2*BCC_CR*BCC_FE*BCC_VA*(BCC_CR - BCC_FE) - 932.5*BCC_CR*BCC_FE*BCC_VA + '
               '311.5*BCC_CR*BCC_VA - '
               '1043.0*BCC_FE*BCC_VA,-8.13674105561218e-49*T^15/(0.525599232981783*BCC_CR*BCC_FE*BCC_'
               'VA*(BCC_CR - BCC_FE) - 0.894055608820709*BCC_CR*BCC_FE*BCC_VA + '
               '0.298657718120805*BCC_CR*BCC_VA - BCC_FE*BCC_VA + 9.58772770853308e-13)^15 - '
               '4.65558036243985e-30*T^9/(0.525599232981783*BCC_CR*BCC_FE*BCC_VA*(BCC_CR - BCC_FE) - '
               '0.894055608820709*BCC_CR*BCC_FE*BCC_VA + 0.298657718120805*BCC_CR*BCC_VA - '
               'BCC_FE*BCC_VA + 9.58772770853308e-13)^9 - '
               '1.3485349181899e-10*T^3/(0.525599232981783*BCC_CR*BCC_FE*BCC_VA*(BCC_CR - BCC_FE) - '
               '0.894055608820709*BCC_CR*BCC_FE*BCC_VA + 0.298657718120805*BCC_CR*BCC_VA - '
               'BCC_FE*BCC_VA + 9.58772770853308e-13)^3 + 1 - '
               '0.905299382744392*(548.2*BCC_CR*BCC_FE*BCC_VA*(BCC_CR - BCC_FE) - '
               '932.5*BCC_CR*BCC_FE*BCC_VA + 311.5*BCC_CR*BCC_VA - 1043.0*BCC_FE*BCC_VA + '
               '1.0e-9)/T,if(T < -548.2*BCC_CR*BCC_FE*BCC_VA*(BCC_CR - BCC_FE) + '
               '932.5*BCC_CR*BCC_FE*BCC_VA - 311.5*BCC_CR*BCC_VA + '
               '1043.0*BCC_FE*BCC_VA,-8.13674105561218e-49*T^15/(-0.525599232981783*BCC_CR*BCC_FE*BCC'
               '_VA*(BCC_CR - BCC_FE) + 0.894055608820709*BCC_CR*BCC_FE*BCC_VA - '
               '0.298657718120805*BCC_CR*BCC_VA + BCC_FE*BCC_VA + 9.58772770853308e-13)^15 - '
               '4.65558036243985e-30*T^9/(-0.525599232981783*BCC_CR*BCC_FE*BCC_VA*(BCC_CR - BCC_FE) '
               '+ 0.894055608820709*BCC_CR*BCC_FE*BCC_VA - 0.298657718120805*BCC_CR*BCC_VA + '
               'BCC_FE*BCC_VA + 9.58772770853308e-13)^9 - '
               '1.3485349181899e-10*T^3/(-0.525599232981783*BCC_CR*BCC_FE*BCC_VA*(BCC_CR - BCC_FE) + '
               '0.894055608820709*BCC_CR*BCC_FE*BCC_VA - 0.298657718120805*BCC_CR*BCC_VA + '
               'BCC_FE*BCC_VA + 9.58772770853308e-13)^3 + 1 - '
               '0.905299382744392*(-548.2*BCC_CR*BCC_FE*BCC_VA*(BCC_CR - BCC_FE) + '
               '932.5*BCC_CR*BCC_FE*BCC_VA - 311.5*BCC_CR*BCC_VA + 1043.0*BCC_FE*BCC_VA + '
               '1.0e-9)/T,if(T > -548.2*BCC_CR*BCC_FE*BCC_VA*(BCC_CR - BCC_FE) + '
               '932.5*BCC_CR*BCC_FE*BCC_VA - 311.5*BCC_CR*BCC_VA + 1043.0*BCC_FE*BCC_VA & '
               '548.2*BCC_CR*BCC_FE*BCC_VA*(BCC_CR - BCC_FE) - 932.5*BCC_CR*BCC_FE*BCC_VA + '
               '311.5*BCC_CR*BCC_VA - 1043.0*BCC_FE*BCC_VA < '
               '0,-79209031311018.7*(-0.525599232981783*BCC_CR*BCC_FE*BCC_VA*(BCC_CR - BCC_FE) + '
               '0.894055608820709*BCC_CR*BCC_FE*BCC_VA - 0.298657718120805*BCC_CR*BCC_VA + '
               'BCC_FE*BCC_VA + 9.58772770853308e-13)^5/T^5 - '
               '3.83095660520737e+42*(-0.525599232981783*BCC_CR*BCC_FE*BCC_VA*(BCC_CR - BCC_FE) + '
               '0.894055608820709*BCC_CR*BCC_FE*BCC_VA - 0.298657718120805*BCC_CR*BCC_VA + '
               'BCC_FE*BCC_VA + 9.58772770853308e-13)^15/T^15 - '
               '1.22565886734485e+72*(-0.525599232981783*BCC_CR*BCC_FE*BCC_VA*(BCC_CR - BCC_FE) + '
               '0.894055608820709*BCC_CR*BCC_FE*BCC_VA - 0.298657718120805*BCC_CR*BCC_VA + '
               'BCC_FE*BCC_VA + 9.58772770853308e-13)^25/T^25,if(T > '
               '548.2*BCC_CR*BCC_FE*BCC_VA*(BCC_CR - BCC_FE) - 932.5*BCC_CR*BCC_FE*BCC_VA + '
               '311.5*BCC_CR*BCC_VA - 1043.0*BCC_FE*BCC_VA & 548.2*BCC_CR*BCC_FE*BCC_VA*(BCC_CR - '
               'BCC_FE) - 932.5*BCC_CR*BCC_FE*BCC_VA + 311.5*BCC_CR*BCC_VA - 1043.0*BCC_FE*BCC_VA > '
               '0,-79209031311018.7*(0.525599232981783*BCC_CR*BCC_FE*BCC_VA*(BCC_CR - BCC_FE) - '
               '0.894055608820709*BCC_CR*BCC_FE*BCC_VA + 0.298657718120805*BCC_CR*BCC_VA - '
               'BCC_FE*BCC_VA + 9.58772770853308e-13)^5/T^5 - '
               '3.83095660520737e+42*(0.525599232981783*BCC_CR*BCC_FE*BCC_VA*(BCC_CR - BCC_FE) - '
               '0.894055608820709*BCC_CR*BCC_FE*BCC_VA + 0.298657718120805*BCC_CR*BCC_VA - '
               'BCC_FE*BCC_VA + 9.58772770853308e-13)^15/T^15 - '
               '1.22565886734485e+72*(0.525599232981783*BCC_CR*BCC_FE*BCC_VA*(BCC_CR - BCC_FE) - '
               '0.894055608820709*BCC_CR*BCC_FE*BCC_VA + 0.298657718120805*BCC_CR*BCC_VA - '
               'BCC_FE*BCC_VA + 9.58772770853308e-13)^25/T^25,0))))*log((2.15*BCC_CR*BCC_FE*BCC_VA - '
               '0.008*BCC_CR*BCC_VA + 2.22*BCC_FE*BCC_VA)*if(2.15*BCC_CR*BCC_FE*BCC_VA - '
               '0.008*BCC_CR*BCC_VA + 2.22*BCC_FE*BCC_VA <= 0,-1.0,1.0) + 1)/(BCC_CR + BCC_FE) + '
               '1.0*(BCC_CR*BCC_VA*if(T >= 298.15 & T < 2180.0,139250.0*1/T - 26.908*T*log(T) + '
               '157.48*T + 0.00189435*T^2.0 - 1.47721e-6*T^3.0 - 8856.94,if(T >= 2180.0 & T < '
               '6000.0,-2.88526e+32*T^(-9.0) - 50.0*T*log(T) + 344.18*T - 34869.344,0)) + '
               'BCC_FE*BCC_VA*if(T >= 298.15 & T < 1811.0,77358.5*1/T - 23.5143*T*log(T) + 124.134*T '
               '- 0.00439752*T^2.0 - 5.89269e-8*T^3.0 + 1225.7,if(T >= 1811.0 & T < '
               '6000.0,2.2960305e+31*T^(-9.0) - 46.0*T*log(T) + 299.31255*T - 25383.581,0)))/(BCC_CR '
               '+ BCC_FE) + 1.0*(BCC_CR*BCC_FE*BCC_VA*(500.0 - 1.5*T)*(BCC_CR - BCC_FE) + '
               'BCC_CR*BCC_FE*BCC_VA*(24600.0 - 14.98*T) + BCC_CR*BCC_FE*BCC_VA*(9.15*T - '
               '14000.0)*(BCC_CR - BCC_FE)^2)/(BCC_CR + BCC_FE); G/100000'
    coupled_variables = 'BCC_CR'
    constant_names = 'BCC_VA T eps'
    constant_expressions = '1 1000 0.01'
  []
  [F_SIGMA]
    type = DerivativeParsedMaterial
    property_name = F_SIGMA
    outputs = exodus
    output_properties = F_SIGMA
    expression = 'SIGMA_0FE := 1-SIGMA_0CR; SIGMA_1FE := 1-SIGMA_1CR; SIGMA_2FE := 1-SIGMA_2CR; G := '
               '8.3145*T*(10.0*if(SIGMA_0CR > 1.0e-15,SIGMA_0CR*plog(SIGMA_0CR,eps),0) + '
               '10.0*if(SIGMA_0FE > 1.0e-15,SIGMA_0FE*plog(SIGMA_0FE,eps),0) + 4.0*if(SIGMA_1CR > '
               '1.0e-15,SIGMA_1CR*plog(SIGMA_1CR,eps),0) + 4.0*if(SIGMA_1FE > '
               '1.0e-15,SIGMA_1FE*plog(SIGMA_1FE,eps),0) + 16.0*if(SIGMA_2CR > '
               '1.0e-15,SIGMA_2CR*plog(SIGMA_2CR,eps),0) + 16.0*if(SIGMA_2FE > '
               '1.0e-15,SIGMA_2FE*plog(SIGMA_2FE,eps),0))/(10.0*SIGMA_0CR + 10.0*SIGMA_0FE + '
               '4.0*SIGMA_1CR + 4.0*SIGMA_1FE + 16.0*SIGMA_2CR + 16.0*SIGMA_2FE) + '
               '(SIGMA_0FE*SIGMA_1CR*SIGMA_2CR*SIGMA_2FE*(-70.0*T - 170400.0) + '
               'SIGMA_0FE*SIGMA_1FE*SIGMA_2CR*SIGMA_2FE*(-10.0*T - 330839.0))/(10.0*SIGMA_0CR + '
               '10.0*SIGMA_0FE + 4.0*SIGMA_1CR + 4.0*SIGMA_1FE + 16.0*SIGMA_2CR + 16.0*SIGMA_2FE) + '
               '(SIGMA_0CR*SIGMA_1CR*SIGMA_2CR*(30.0*if(T >= 298.15 & T < 2180.0,139250.0*1/T - '
               '26.908*T*log(T) + 157.48*T + 0.00189435*T^2.0 - 1.47721e-6*T^3.0 - 8856.94,if(T >= '
               '2180.0 & T < 6000.0,-2.88526e+32*T^(-9.0) - 50.0*T*log(T) + 344.18*T - 34869.344,0)) '
               '+ 132000.0) + SIGMA_0CR*SIGMA_1CR*SIGMA_2FE*(-110.0*T + 16.0*if(T >= 298.15 & T < '
               '1811.0,77358.5*1/T - 23.5143*T*log(T) + 124.134*T - 0.00439752*T^2.0 - '
               '5.89269e-8*T^3.0 + 1225.7,if(T >= 1811.0 & T < 6000.0,2.2960305e+31*T^(-9.0) - '
               '46.0*T*log(T) + 299.31255*T - 25383.581,0)) + 14.0*if(T >= 298.15 & T < '
               '2180.0,139250.0*1/T - 26.908*T*log(T) + 157.48*T + 0.00189435*T^2.0 - '
               '1.47721e-6*T^3.0 - 8856.94,if(T >= 2180.0 & T < 6000.0,-2.88526e+32*T^(-9.0) - '
               '50.0*T*log(T) + 344.18*T - 34869.344,0)) + 123500.0) + '
               'SIGMA_0CR*SIGMA_1FE*SIGMA_2CR*(4.0*if(T >= 298.15 & T < 1811.0,77358.5*1/T - '
               '23.5143*T*log(T) + 124.134*T - 0.00439752*T^2.0 - 5.89269e-8*T^3.0 + 1225.7,if(T >= '
               '1811.0 & T < 6000.0,2.2960305e+31*T^(-9.0) - 46.0*T*log(T) + 299.31255*T - '
               '25383.581,0)) + 26.0*if(T >= 298.15 & T < 2180.0,139250.0*1/T - 26.908*T*log(T) + '
               '157.48*T + 0.00189435*T^2.0 - 1.47721e-6*T^3.0 - 8856.94,if(T >= 2180.0 & T < '
               '6000.0,-2.88526e+32*T^(-9.0) - 50.0*T*log(T) + 344.18*T - 34869.344,0)) + 140486.0) '
               '+ SIGMA_0CR*SIGMA_1FE*SIGMA_2FE*(20.0*if(T >= 298.15 & T < 1811.0,77358.5*1/T - '
               '23.5143*T*log(T) + 124.134*T - 0.00439752*T^2.0 - 5.89269e-8*T^3.0 + 1225.7,if(T >= '
               '1811.0 & T < 6000.0,2.2960305e+31*T^(-9.0) - 46.0*T*log(T) + 299.31255*T - '
               '25383.581,0)) + 10.0*if(T >= 298.15 & T < 2180.0,139250.0*1/T - 26.908*T*log(T) + '
               '157.48*T + 0.00189435*T^2.0 - 1.47721e-6*T^3.0 - 8856.94,if(T >= 2180.0 & T < '
               '6000.0,-2.88526e+32*T^(-9.0) - 50.0*T*log(T) + 344.18*T - 34869.344,0)) + 148800.0) '
               '+ SIGMA_0FE*SIGMA_1CR*SIGMA_2CR*(10.0*if(T >= 298.15 & T < 1811.0,77358.5*1/T - '
               '23.5143*T*log(T) + 124.134*T - 0.00439752*T^2.0 - 5.89269e-8*T^3.0 + 1225.7,if(T >= '
               '1811.0 & T < 6000.0,2.2960305e+31*T^(-9.0) - 46.0*T*log(T) + 299.31255*T - '
               '25383.581,0)) + 20.0*if(T >= 298.15 & T < 2180.0,139250.0*1/T - 26.908*T*log(T) + '
               '157.48*T + 0.00189435*T^2.0 - 1.47721e-6*T^3.0 - 8856.94,if(T >= 2180.0 & T < '
               '6000.0,-2.88526e+32*T^(-9.0) - 50.0*T*log(T) + 344.18*T - 34869.344,0)) + 56200.0) + '
               'SIGMA_0FE*SIGMA_1CR*SIGMA_2FE*(26.0*if(T >= 298.15 & T < 1811.0,77358.5*1/T - '
               '23.5143*T*log(T) + 124.134*T - 0.00439752*T^2.0 - 5.89269e-8*T^3.0 + 1225.7,if(T >= '
               '1811.0 & T < 6000.0,2.2960305e+31*T^(-9.0) - 46.0*T*log(T) + 299.31255*T - '
               '25383.581,0)) + 4.0*if(T >= 298.15 & T < 2180.0,139250.0*1/T - 26.908*T*log(T) + '
               '157.48*T + 0.00189435*T^2.0 - 1.47721e-6*T^3.0 - 8856.94,if(T >= 2180.0 & T < '
               '6000.0,-2.88526e+32*T^(-9.0) - 50.0*T*log(T) + 344.18*T - 34869.344,0)) + 152700.0) '
               '+ SIGMA_0FE*SIGMA_1FE*SIGMA_2CR*(14.0*if(T >= 298.15 & T < 1811.0,77358.5*1/T - '
               '23.5143*T*log(T) + 124.134*T - 0.00439752*T^2.0 - 5.89269e-8*T^3.0 + 1225.7,if(T >= '
               '1811.0 & T < 6000.0,2.2960305e+31*T^(-9.0) - 46.0*T*log(T) + 299.31255*T - '
               '25383.581,0)) + 16.0*if(T >= 298.15 & T < 2180.0,139250.0*1/T - 26.908*T*log(T) + '
               '157.48*T + 0.00189435*T^2.0 - 1.47721e-6*T^3.0 - 8856.94,if(T >= 2180.0 & T < '
               '6000.0,-2.88526e+32*T^(-9.0) - 50.0*T*log(T) + 344.18*T - 34869.344,0)) + 46200.0) + '
               'SIGMA_0FE*SIGMA_1FE*SIGMA_2FE*(30.0*if(T >= 298.15 & T < 1811.0,77358.5*1/T - '
               '23.5143*T*log(T) + 124.134*T - 0.00439752*T^2.0 - 5.89269e-8*T^3.0 + 1225.7,if(T >= '
               '1811.0 & T < 6000.0,2.2960305e+31*T^(-9.0) - 46.0*T*log(T) + 299.31255*T - '
               '25383.581,0)) + 173333.0))/(10.0*SIGMA_0CR + 10.0*SIGMA_0FE + 4.0*SIGMA_1CR + '
               '4.0*SIGMA_1FE + 16.0*SIGMA_2CR + 16.0*SIGMA_2FE); G/100000'
    coupled_variables = 'SIGMA_0CR SIGMA_1CR SIGMA_2CR'
    constant_names = 'T eps'
    constant_expressions = '1000 0.01'
  []
  # h(eta)
  [h1]
    type = SwitchingFunctionMaterial
    function_name = h1
    h_order = HIGH
    eta = eta1
  []
  [h2]
    type = SwitchingFunctionMaterial
    function_name = h2
    h_order = HIGH
    eta = eta2
  []
  # g(eta)
  [g1]
    type = BarrierFunctionMaterial
    function_name = g1
    g_order = SIMPLE
    eta = eta1
  []
  [g2]
    type = BarrierFunctionMaterial
    function_name = g2
    g_order = SIMPLE
    eta = eta2
  []
  # constant properties
  [constants]
    type = GenericConstantMaterial
    prop_names = 'D   L   kappa'
    prop_values = '10  1   0.1  '
  []
  # Coefficients for diffusion equation
  [Dh1]
    type = DerivativeParsedMaterial
    material_property_names = 'D h1(eta1)'
    expression = D*h1
    property_name = Dh1
    coupled_variables = eta1
    derivative_order = 1
  []
  [Dh2a]
    type = DerivativeParsedMaterial
    material_property_names = 'D h2(eta2)'
    expression = D*h2*10/30
    property_name = Dh2a
    coupled_variables = eta2
    derivative_order = 1
  []
  [Dh2b]
    type = DerivativeParsedMaterial
    material_property_names = 'D h2(eta2)'
    expression = D*h2*4/30
    property_name = Dh2b
    coupled_variables = eta2
    derivative_order = 1
  []
  [Dh2c]
    type = DerivativeParsedMaterial
    material_property_names = 'D h2(eta2)'
    expression = D*h2*16/30
    property_name = Dh2c
    coupled_variables = eta2
    derivative_order = 1
  []
[]
[Kernels]
  #Kernels for diffusion equation
  [diff_time]
    type = TimeDerivative
    variable = cCr
  []
  [diff_c1]
    type = MatDiffusion
    variable = cCr
    diffusivity = Dh1
    v = BCC_CR
    args = eta1
  []
  [diff_c2a]
    type = MatDiffusion
    variable = cCr
    diffusivity = Dh2a
    v = SIGMA_0CR
    args = eta2
  []
  [diff_c2b]
    type = MatDiffusion
    variable = cCr
    diffusivity = Dh2b
    v = SIGMA_1CR
    args = eta2
  []
  [diff_c2c]
    type = MatDiffusion
    variable = cCr
    diffusivity = Dh2c
    v = SIGMA_2CR
    args = eta2
  []
  # enforce pointwise equality of chemical potentials
  [chempot1a2a]
    # The BCC phase has only one sublattice
    # we tie it to the first sublattice with site fraction 10/(10+4+16) in the sigma phase
    type = KKSPhaseChemicalPotential
    variable = BCC_CR
    cb = SIGMA_0CR
    kb = '${fparse 10/30}'
    fa_name = F_BCC_A2
    fb_name = F_SIGMA
    args_b = 'SIGMA_1CR SIGMA_2CR'
  []
  [chempot2a2b]
    # This kernel ties the first two sublattices in the sigma phase together
    type = SLKKSChemicalPotential
    variable = SIGMA_0CR
    a = 10
    cs = SIGMA_1CR
    as = 4
    F = F_SIGMA
    coupled_variables = 'SIGMA_2CR'
  []
  [chempot2b2c]
    # This kernel ties the remaining two sublattices in the sigma phase together
    type = SLKKSChemicalPotential
    variable = SIGMA_1CR
    a = 4
    cs = SIGMA_2CR
    as = 16
    F = F_SIGMA
    coupled_variables = 'SIGMA_0CR'
  []
  [phaseconcentration]
    # This kernel ties the sum of the sublattice concentrations to the global concentration cCr
    type = SLKKSMultiPhaseConcentration
    variable = SIGMA_2CR
    c = cCr
    ns = '1      3'
    as = '1      10        4         16'
    cs = 'BCC_CR SIGMA_0CR SIGMA_1CR SIGMA_2CR'
    h_names = 'h1   h2'
    eta = 'eta1 eta2'
  []
  # Kernels for Allen-Cahn equation for eta1
  [deta1dt]
    type = TimeDerivative
    variable = eta1
  []
  [ACBulkF1]
    type = KKSMultiACBulkF
    variable = eta1
    Fj_names = 'F_BCC_A2 F_SIGMA'
    hj_names = 'h1    h2'
    gi_name = g1
    eta_i = eta1
    wi = 0.1
    coupled_variables = 'BCC_CR SIGMA_0CR SIGMA_1CR SIGMA_2CR eta2'
  []
  [ACBulkC1]
    type = SLKKSMultiACBulkC
    variable = eta1
    F = F_BCC_A2
    c = BCC_CR
    ns = '1      3'
    as = '1      10        4         16'
    cs = 'BCC_CR SIGMA_0CR SIGMA_1CR SIGMA_2CR'
    h_names = 'h1   h2'
    eta = 'eta1 eta2'
  []
  [ACInterface1]
    type = ACInterface
    variable = eta1
    kappa_name = kappa
  []
  [lagrange1]
    type = SwitchingFunctionConstraintEta
    variable = eta1
    h_name = h1
    lambda = lambda
    coupled_variables = 'eta2'
  []
  # Kernels for Allen-Cahn equation for eta1
  [deta2dt]
    type = TimeDerivative
    variable = eta2
  []
  [ACBulkF2]
    type = KKSMultiACBulkF
    variable = eta2
    Fj_names = 'F_BCC_A2 F_SIGMA'
    hj_names = 'h1    h2'
    gi_name = g2
    eta_i = eta2
    wi = 0.1
    coupled_variables = 'BCC_CR SIGMA_0CR SIGMA_1CR SIGMA_2CR eta1'
  []
  [ACBulkC2]
    type = SLKKSMultiACBulkC
    variable = eta2
    F = F_BCC_A2
    c = BCC_CR
    ns = '1      3'
    as = '1      10        4         16'
    cs = 'BCC_CR SIGMA_0CR SIGMA_1CR SIGMA_2CR'
    h_names = 'h1   h2'
    eta = 'eta1 eta2'
  []
  [ACInterface2]
    type = ACInterface
    variable = eta2
    kappa_name = kappa
  []
  [lagrange2]
    type = SwitchingFunctionConstraintEta
    variable = eta2
    h_name = h2
    lambda = lambda
    coupled_variables = 'eta1'
  []
  # Lagrange-multiplier constraint kernel for lambda
  [lagrange]
    type = SwitchingFunctionConstraintLagrange
    variable = lambda
    h_names = 'h1   h2'
    etas = 'eta1 eta2'
    epsilon = 1e-6
  []
[]
[AuxKernels]
  [GlobalFreeEnergy]
    type = KKSMultiFreeEnergy
    variable = Fglobal
    Fj_names = 'F_BCC_A2 F_SIGMA'
    hj_names = 'h1 h2'
    gj_names = 'g1 g2'
    interfacial_vars = 'eta1 eta2'
    kappa_names = 'kappa kappa'
    w = 0.1
  []
[]
[Executioner]
  type = Transient
  solve_type = 'NEWTON'
  line_search = none
  petsc_options_iname = '-pc_type -sub_pc_type -sub_pc_factor_shift_type -ksp_gmres_restart'
  petsc_options_value = 'asm      lu          nonzero                    30'
  l_max_its = 100
  nl_max_its = 20
  nl_abs_tol = 1e-10
  end_time = 1000
  [TimeStepper]
    type = IterationAdaptiveDT
    optimal_iterations = 12
    iteration_window = 2
    growth_factor = 2
    cutback_factor = 0.5
    dt = 0.1
  []
[]
[Postprocessors]
  [F]
    type = ElementIntegralVariablePostprocessor
    variable = Fglobal
  []
  [cmin]
    type = NodalExtremeValue
    value_type = min
    variable = cCr
  []
  [cmax]
    type = NodalExtremeValue
    value_type = max
    variable = cCr
  []
[]
[Outputs]
  exodus = true
  print_linear_residuals = false
  # exclude lagrange multiplier from output, it can diff more easily
  hide = lambda
[]
(modules/combined/examples/phase_field-mechanics/Pattern1.i)
#
# Pattern example 1
#
# Phase changes driven by a combination mechanical (elastic) and chemical
# driving forces. In this three phase system a matrix phase, an oversized and
# an undersized precipitate phase compete. The chemical free energy favors a
# phase separation into either precipitate phase. A mix of both precipitate
# emerges to balance lattice expansion and contraction.
#
# This example demonstrates the use of
# * ACMultiInterface
# * SwitchingFunctionConstraintEta and SwitchingFunctionConstraintLagrange
# * DerivativeParsedMaterial
# * ElasticEnergyMaterial
# * DerivativeMultiPhaseMaterial
# * MultiPhaseStressMaterial
# which are the components to se up a phase field model with an arbitrary number
# of phases
#
[Mesh]
  type = GeneratedMesh
  dim = 2
  nx = 80
  ny = 80
  nz = 0
  xmin = -20
  xmax = 20
  ymin = -20
  ymax = 20
  zmin = 0
  zmax = 0
  elem_type = QUAD4
[]
[GlobalParams]
  # CahnHilliard needs the third derivatives
  derivative_order = 3
  enable_jit = true
  displacements = 'disp_x disp_y'
[]
# AuxVars to compute the free energy density for outputting
[AuxVariables]
  [./local_energy]
    order = CONSTANT
    family = MONOMIAL
  [../]
  [./cross_energy]
    order = CONSTANT
    family = MONOMIAL
  [../]
[]
[AuxKernels]
  [./local_free_energy]
    type = TotalFreeEnergy
    variable = local_energy
    interfacial_vars = 'c'
    kappa_names = 'kappa_c'
    additional_free_energy = cross_energy
  [../]
  [./cross_terms]
    type = CrossTermGradientFreeEnergy
    variable = cross_energy
    interfacial_vars = 'eta1 eta2 eta3'
    kappa_names = 'kappa11 kappa12 kappa13
                   kappa21 kappa22 kappa23
                   kappa31 kappa32 kappa33'
  [../]
[]
[Variables]
  # Solute concentration variable
  [./c]
    order = FIRST
    family = LAGRANGE
    [./InitialCondition]
      type = RandomIC
      min = 0
      max = 0.8
      seed = 1235
    [../]
  [../]
  # Order parameter for the Matrix
  [./eta1]
    order = FIRST
    family = LAGRANGE
    initial_condition = 0.5
  [../]
  # Order parameters for the 2 different inclusion orientations
  [./eta2]
    order = FIRST
    family = LAGRANGE
    initial_condition = 0.1
  [../]
  [./eta3]
    order = FIRST
    family = LAGRANGE
    initial_condition = 0.1
  [../]
  # Mesh displacement
  [./disp_x]
    order = FIRST
    family = LAGRANGE
  [../]
  [./disp_y]
    order = FIRST
    family = LAGRANGE
  [../]
  # Lagrange-multiplier
  [./lambda]
    order = FIRST
    family = LAGRANGE
    initial_condition = 1.0
  [../]
[]
[Kernels]
  # Set up stress divergence kernels
  [./TensorMechanics]
  [../]
  # Cahn-Hilliard kernels
  [./c_res]
    type = CahnHilliard
    variable = c
    f_name = F
    coupled_variables = 'eta1 eta2 eta3'
  [../]
  [./time]
    type = TimeDerivative
    variable = c
  [../]
  # Allen-Cahn and Lagrange-multiplier constraint kernels for order parameter 1
  [./deta1dt]
    type = TimeDerivative
    variable = eta1
  [../]
  [./ACBulk1]
    type = AllenCahn
    variable = eta1
    coupled_variables = 'eta2 eta3 c'
    mob_name = L1
    f_name = F
  [../]
  [./ACInterface1]
    type = ACMultiInterface
    variable = eta1
    etas = 'eta1 eta2 eta3'
    mob_name = L1
    kappa_names = 'kappa11 kappa12 kappa13'
  [../]
  [./lagrange1]
    type = SwitchingFunctionConstraintEta
    variable = eta1
    h_name   = h1
    lambda = lambda
  [../]
  # Allen-Cahn and Lagrange-multiplier constraint kernels for order parameter 2
  [./deta2dt]
    type = TimeDerivative
    variable = eta2
  [../]
  [./ACBulk2]
    type = AllenCahn
    variable = eta2
    coupled_variables = 'eta1 eta3 c'
    mob_name = L2
    f_name = F
  [../]
  [./ACInterface2]
    type = ACMultiInterface
    variable = eta2
    etas = 'eta1 eta2 eta3'
    mob_name = L2
    kappa_names = 'kappa21 kappa22 kappa23'
  [../]
  [./lagrange2]
    type = SwitchingFunctionConstraintEta
    variable = eta2
    h_name   = h2
    lambda = lambda
  [../]
  # Allen-Cahn and Lagrange-multiplier constraint kernels for order parameter 3
  [./deta3dt]
    type = TimeDerivative
    variable = eta3
  [../]
  [./ACBulk3]
    type = AllenCahn
    variable = eta3
    coupled_variables = 'eta1 eta2 c'
    mob_name = L3
    f_name = F
  [../]
  [./ACInterface3]
    type = ACMultiInterface
    variable = eta3
    etas = 'eta1 eta2 eta3'
    mob_name = L3
    kappa_names = 'kappa31 kappa32 kappa33'
  [../]
  [./lagrange3]
    type = SwitchingFunctionConstraintEta
    variable = eta3
    h_name   = h3
    lambda = lambda
  [../]
  # Lagrange-multiplier constraint kernel for lambda
  [./lagrange]
    type = SwitchingFunctionConstraintLagrange
    variable = lambda
    etas    = 'eta1 eta2 eta3'
    h_names = 'h1   h2   h3'
    epsilon = 1e-6
  [../]
[]
[Materials]
  # declare a few constants, such as mobilities (L,M) and interface gradient prefactors (kappa*)
  [./consts]
    type = GenericConstantMaterial
    prop_names  = 'M   kappa_c  L1 L2 L3  kappa11 kappa12 kappa13 kappa21 kappa22 kappa23 kappa31 kappa32 kappa33'
    prop_values = '0.2 0        1  1  1   2.00    2.00    2.00    2.00    2.00    2.00    2.00    2.00    2.00   '
  [../]
  # We use this to output the level of constraint enforcement
  # ideally it should be 0 everywhere, if the constraint is fully enforced
  [./etasummat]
    type = ParsedMaterial
    property_name = etasum
    coupled_variables = 'eta1 eta2 eta3'
    material_property_names = 'h1 h2 h3'
    expression = 'h1+h2+h3-1'
    outputs = exodus
  [../]
  # This parsed material creates a single property for visualization purposes.
  # It will be 0 for phase 1, -1 for phase 2, and 1 for phase 3
  [./phasemap]
    type = ParsedMaterial
    property_name = phase
    coupled_variables = 'eta2 eta3'
    expression = 'if(eta3>0.5,1,0)-if(eta2>0.5,1,0)'
    outputs = exodus
  [../]
  # matrix phase
  [./elasticity_tensor_1]
    type = ComputeElasticityTensor
    base_name = phase1
    C_ijkl = '3 3'
    fill_method = symmetric_isotropic
  [../]
  [./strain_1]
    type = ComputeSmallStrain
    base_name = phase1
    displacements = 'disp_x disp_y'
  [../]
  [./stress_1]
    type = ComputeLinearElasticStress
    base_name = phase1
  [../]
  # oversized phase
  [./elasticity_tensor_2]
    type = ComputeElasticityTensor
    base_name = phase2
    C_ijkl = '7 7'
    fill_method = symmetric_isotropic
  [../]
  [./strain_2]
    type = ComputeSmallStrain
    base_name = phase2
    displacements = 'disp_x disp_y'
    eigenstrain_names = eigenstrain
  [../]
  [./stress_2]
    type = ComputeLinearElasticStress
    base_name = phase2
  [../]
  [./eigenstrain_2]
    type = ComputeEigenstrain
    base_name = phase2
    eigen_base = '0.02'
    eigenstrain_name = eigenstrain
  [../]
  # undersized phase
  [./elasticity_tensor_3]
    type = ComputeElasticityTensor
    base_name = phase3
    C_ijkl = '7 7'
    fill_method = symmetric_isotropic
  [../]
  [./strain_3]
    type = ComputeSmallStrain
    base_name = phase3
    displacements = 'disp_x disp_y'
    eigenstrain_names = eigenstrain
  [../]
  [./stress_3]
    type = ComputeLinearElasticStress
    base_name = phase3
  [../]
  [./eigenstrain_3]
    type = ComputeEigenstrain
    base_name = phase3
    eigen_base = '-0.05'
    eigenstrain_name = eigenstrain
  [../]
  # switching functions
  [./switching1]
    type = SwitchingFunctionMaterial
    function_name = h1
    eta = eta1
    h_order = SIMPLE
  [../]
  [./switching2]
    type = SwitchingFunctionMaterial
    function_name = h2
    eta = eta2
    h_order = SIMPLE
  [../]
  [./switching3]
    type = SwitchingFunctionMaterial
    function_name = h3
    eta = eta3
    h_order = SIMPLE
  [../]
  [./barrier]
    type = MultiBarrierFunctionMaterial
    etas = 'eta1 eta2 eta3'
  [../]
  # chemical free energies
  [./chemical_free_energy_1]
    type = DerivativeParsedMaterial
    property_name = Fc1
    expression = '4*c^2'
    coupled_variables = 'c'
    derivative_order = 2
  [../]
  [./chemical_free_energy_2]
    type = DerivativeParsedMaterial
    property_name = Fc2
    expression = '(c-0.9)^2-0.4'
    coupled_variables = 'c'
    derivative_order = 2
  [../]
  [./chemical_free_energy_3]
    type = DerivativeParsedMaterial
    property_name = Fc3
    expression = '(c-0.9)^2-0.5'
    coupled_variables = 'c'
    derivative_order = 2
  [../]
  # elastic free energies
  [./elastic_free_energy_1]
    type = ElasticEnergyMaterial
    base_name = phase1
    f_name = Fe1
    derivative_order = 2
    coupled_variables = 'c' # should be empty
  [../]
  [./elastic_free_energy_2]
    type = ElasticEnergyMaterial
    base_name = phase2
    f_name = Fe2
    derivative_order = 2
    coupled_variables = 'c' # should be empty
  [../]
  [./elastic_free_energy_3]
    type = ElasticEnergyMaterial
    base_name = phase3
    f_name = Fe3
    derivative_order = 2
    coupled_variables = 'c' # should be empty
  [../]
  # phase free energies (chemical + elastic)
  [./phase_free_energy_1]
    type = DerivativeSumMaterial
    property_name = F1
    sum_materials = 'Fc1 Fe1'
    coupled_variables = 'c'
    derivative_order = 2
  [../]
  [./phase_free_energy_2]
    type = DerivativeSumMaterial
    property_name = F2
    sum_materials = 'Fc2 Fe2'
    coupled_variables = 'c'
    derivative_order = 2
  [../]
  [./phase_free_energy_3]
    type = DerivativeSumMaterial
    property_name = F3
    sum_materials = 'Fc3 Fe3'
    coupled_variables = 'c'
    derivative_order = 2
  [../]
  # global free energy
  [./free_energy]
    type = DerivativeMultiPhaseMaterial
    f_name = F
    fi_names = 'F1  F2  F3'
    hi_names = 'h1  h2  h3'
    etas     = 'eta1 eta2 eta3'
    coupled_variables = 'c'
    W = 3
  [../]
  # Generate the global stress from the phase stresses
  [./global_stress]
    type = MultiPhaseStressMaterial
    phase_base = 'phase1 phase2 phase3'
    h          = 'h1     h2     h3'
  [../]
[]
[BCs]
  # the boundary conditions on the displacement enforce periodicity
  # at zero total shear and constant volume
  [./bottom_y]
    type = DirichletBC
    variable = disp_y
    boundary = 'bottom'
    value = 0
  [../]
  [./top_y]
    type = DirichletBC
    variable = disp_y
    boundary = 'top'
    value = 0
  [../]
  [./left_x]
    type = DirichletBC
    variable = disp_x
    boundary = 'left'
    value = 0
  [../]
  [./right_x]
    type = DirichletBC
    variable = disp_x
    boundary = 'right'
    value = 0
  [../]
  [./Periodic]
    [./disp_x]
      auto_direction = 'y'
    [../]
    [./disp_y]
      auto_direction = 'x'
    [../]
    # all other phase field variables are fully periodic
    [./c]
      auto_direction = 'x y'
    [../]
    [./eta1]
      auto_direction = 'x y'
    [../]
    [./eta2]
      auto_direction = 'x y'
    [../]
    [./eta3]
      auto_direction = 'x y'
    [../]
    [./lambda]
      auto_direction = 'x y'
    [../]
  [../]
[]
[Preconditioning]
  [./SMP]
    type = SMP
    full = true
  [../]
[]
# We monitor the total free energy and the total solute concentration (should be constant)
[Postprocessors]
  [./total_free_energy]
    type = ElementIntegralVariablePostprocessor
    variable = local_energy
  [../]
  [./total_solute]
    type = ElementIntegralVariablePostprocessor
    variable = c
  [../]
[]
[Executioner]
  type = Transient
  scheme = bdf2
  solve_type = 'PJFNK'
  petsc_options_iname = '-pc_type -sub_pc_type'
  petsc_options_value = 'asm      ilu'
  l_max_its = 30
  nl_max_its = 10
  l_tol = 1.0e-4
  nl_rel_tol = 1.0e-8
  nl_abs_tol = 1.0e-10
  start_time = 0.0
  num_steps = 200
  [./TimeStepper]
    type = SolutionTimeAdaptiveDT
    dt = 0.1
  [../]
[]
[Outputs]
  execute_on = 'timestep_end'
  exodus = true
  [./table]
    type = CSV
    delimiter = ' '
  [../]
[]
[Debug]
  # show_var_residual_norms = true
[]
(modules/phase_field/test/tests/MultiPhase/acmultiinterface.i)
[Mesh]
  type = GeneratedMesh
  dim = 2
  nx = 20
  ny = 10
  nz = 0
  xmin = -10
  xmax = 10
  ymin = -5
  ymax = 5
  elem_type = QUAD4
[]
[Variables]
  [./eta1]
    order = FIRST
    family = LAGRANGE
    [./InitialCondition]
      type = SmoothCircleIC
      x1 = -3.5
      y1 =  0.0
      radius = 4.0
      invalue = 0.9
      outvalue = 0.1
      int_width = 2.0
    [../]
  [../]
  [./eta2]
    order = FIRST
    family = LAGRANGE
    [./InitialCondition]
      type = SmoothCircleIC
      x1 =  3.5
      y1 =  0.0
      radius = 4.0
      invalue = 0.9
      outvalue = 0.1
      int_width = 2.0
    [../]
  [../]
  [./eta3]
    order = FIRST
    family = LAGRANGE
    [./InitialCondition]
      type = SpecifiedSmoothCircleIC
      x_positions = '-4.0 4.0'
      y_positions = ' 0.0 0.0'
      z_positions = ' 0.0 0.0'
      radii = '4.0 4.0'
      invalue = 0.1
      outvalue = 0.9
      int_width = 2.0
    [../]
  [../]
  [./lambda]
    order = FIRST
    family = LAGRANGE
    initial_condition = 1.0
  [../]
[]
[Kernels]
  [./deta1dt]
    type = TimeDerivative
    variable = eta1
  [../]
  [./ACBulk1]
    type = AllenCahn
    variable = eta1
    coupled_variables = 'eta2 eta3'
    mob_name = L1
    f_name = F
  [../]
  [./ACInterface1]
    type = ACMultiInterface
    variable = eta1
    etas = 'eta1 eta2 eta3'
    mob_name = L1
    kappa_names = 'kappa11 kappa12 kappa13'
  [../]
  [./lagrange1]
    type = SwitchingFunctionConstraintEta
    variable = eta1
    h_name   = h1
    lambda = lambda
  [../]
  [./deta2dt]
    type = TimeDerivative
    variable = eta2
  [../]
  [./ACBulk2]
    type = AllenCahn
    variable = eta2
    coupled_variables = 'eta1 eta3'
    mob_name = L2
    f_name = F
  [../]
  [./ACInterface2]
    type = ACMultiInterface
    variable = eta2
    etas = 'eta1 eta2 eta3'
    mob_name = L2
    kappa_names = 'kappa21 kappa22 kappa23'
  [../]
  [./lagrange2]
    type = SwitchingFunctionConstraintEta
    variable = eta2
    h_name   = h2
    lambda = lambda
  [../]
  [./deta3dt]
    type = TimeDerivative
    variable = eta3
  [../]
  [./ACBulk3]
    type = AllenCahn
    variable = eta3
    coupled_variables = 'eta1 eta2'
    mob_name = L3
    f_name = F
  [../]
  [./ACInterface3]
    type = ACMultiInterface
    variable = eta3
    etas = 'eta1 eta2 eta3'
    mob_name = L3
    kappa_names = 'kappa31 kappa32 kappa33'
  [../]
  [./lagrange3]
    type = SwitchingFunctionConstraintEta
    variable = eta3
    h_name   = h3
    lambda = lambda
  [../]
  [./lagrange]
    type = SwitchingFunctionConstraintLagrange
    variable = lambda
    etas    = 'eta1 eta2 eta3'
    h_names = 'h1   h2   h3'
    epsilon = 0
  [../]
[]
[BCs]
  [./Periodic]
    [./All]
      auto_direction = 'x y'
    [../]
  [../]
[]
[Materials]
  [./consts]
    type = GenericConstantMaterial
    prop_names  = 'Fx  L1 L2 L3  kappa11 kappa12 kappa13 kappa21 kappa22 kappa23 kappa31 kappa32 kappa33'
    prop_values = '0   1  1  1   1       1       1       1       1       1       1       1       1      '
  [../]
  [./etasummat]
    type = ParsedMaterial
    property_name = etasum
    coupled_variables = 'eta1 eta2 eta3'
    material_property_names = 'h1 h2 h3'
    expression = 'h1+h2+h3'
  [../]
  [./switching1]
    type = SwitchingFunctionMaterial
    function_name = h1
    eta = eta1
    h_order = SIMPLE
  [../]
  [./switching2]
    type = SwitchingFunctionMaterial
    function_name = h2
    eta = eta2
    h_order = SIMPLE
  [../]
  [./switching3]
    type = SwitchingFunctionMaterial
    function_name = h3
    eta = eta3
    h_order = SIMPLE
  [../]
  [./barrier]
    type = MultiBarrierFunctionMaterial
    etas = 'eta1 eta2 eta3'
  [../]
  [./free_energy]
    type = DerivativeMultiPhaseMaterial
    property_name = F
    # we use a constant free energy (GeneriConstantmaterial property Fx)
    fi_names = 'Fx  Fx  Fx'
    hi_names = 'h1  h2  h3'
    etas     = 'eta1 eta2 eta3'
    # the free energy is given by the MultiBarrierFunctionMaterial only
    W = 1
    derivative_order = 2
  [../]
[]
[Preconditioning]
  [./SMP]
    type = SMP
    full = true
  [../]
[]
[Executioner]
  type = Transient
  scheme = 'bdf2'
  solve_type = 'PJFNK'
  #petsc_options = '-snes_ksp -snes_ksp_ew'
  #petsc_options = '-ksp_monitor_snes_lg-snes_ksp_ew'
  #petsc_options_iname = '-ksp_gmres_restart'
  #petsc_options_value = '1000              '
  l_max_its = 15
  l_tol = 1.0e-6
  nl_max_its = 50
  nl_rel_tol = 1.0e-8
  nl_abs_tol = 1.0e-10
  start_time = 0.0
  num_steps = 2
  dt = 0.2
[]
[Outputs]
  execute_on = 'timestep_end'
  exodus = true
[]