  # GetDP Electromagnetics general solver 2D
  getdpMicrowavesGeneral: &getdpMicrowavesGeneral
    key: getdpMicrowaves
    command: runGetdp
    DOF_variable: AZ

    constraints:
      - Efield
      - Efield_zero
      # - name: Efield_port
        # assignFromResolution: Initialization


    domain_groups:
      em_nc:
        non_conducting_domain: [this]
      em_cc:
        conducting_domain: [this]
      em_open:
        open_air_domain: [this]


    bc_groups:
      conductingBoundary: Sur_CONDUCTOR
      perfectConductor: Sur_PEC
      uniformPort: Sur_UNIFPORT
      uniformPortN: Sur_UNIFPORT_N
      coaxialPort: Sur_COAXPORT
      radiationBoundary: Sur_RB
      interface: Sur_INTERFACE

    argumentPosition:
      epsilon:
        frequency: 1

    postValues:


#################
# Domain Fields #
#################   
 
      Hfield:
        name: Hfield
        term:
          - $AfScale~{i} * Norm[ Complex[0,1]*nu[]*nu0*{d e}/(2*Pi*$Time*FreqFactor) ]
        type: NODE_FIELD
        safeName: Magnetic_Field,_[A/m] 
        domains:
          - non_conducting_domain, open_air_domain
        smoothing: 1
        hidden: true
        default: true
        
      Hfield_re:
        name: Hfield_re
        term:
          - $AfScale~{i} * Re[Complex[0,1]*nu[]*nu0*{d e}/(2*Pi*$Time*FreqFactor)]
        type: NODE_FIELD
        components: 3
        safeName: Magnetic_Field_re,_[A/m] 
        domains:
          - non_conducting_domain, open_air_domain
        smoothing: 1
        hidden: true
        default: true
        
      Hfield_im:
        name: Hfield_im
        term:
          - $AfScale~{i} * Im[Complex[0,1]*nu[]*nu0*{d e}/(2*Pi*$Time*FreqFactor)]
        type: NODE_FIELD
        components: 3
        safeName: Magnetic_Field_im,_[A/m] 
        domains:
          - non_conducting_domain, open_air_domain
        smoothing: 1
        hidden: true
        default: true
        
      Efield:
        name: Efield
        term:
          - $AfScale~{i} * Norm[ {e} ]
        type: NODE_FIELD
        units: V/m
        safeName: Electric_Field,_[V/m]
        domains:
          - non_conducting_domain, open_air_domain
        smoothing: 1
        hidden: true
        default: true
        
      Efield_re:
        name: Efield_re
        term:
          - $AfScale~{i} * Re[{e}]
        type: NODE_FIELD
        components: 3
        safeName: Electric_Field_re,_[V/m] 
        domains:
          - non_conducting_domain, open_air_domain
        smoothing: 1
        hidden: true
        default: true
        
      Efield_im:
        name: Efield_im
        term:
          - $AfScale~{i} * Im[{e}]
        type: NODE_FIELD
        components: 3
        safeName: Electric_Field_im,_[V/m] 
        domains:
          - non_conducting_domain, open_air_domain
        smoothing: 1
        hidden: true
        default: true    
        
###################
# Boundary Fields #
###################
        
        
      SurEfield:
        name: SurEfield
        term:
          - $AfScale~{i} * Norm[ {e} ]
        type: BOUNDARY_NODE_FIELD
        safeName: Electric_Field,_[V/m] 
        domains:
          - Sur_UNIFPORT_N~{i},  Sur_COAXPORT, Sur_CONDUCTOR, Sur_INTERFACE
        smoothing: 1
        hidden: true
        default: true
        
      SEfield_re:
        name: SEfield_re
        term:
          - $AfScale~{i} * Re[{e}]
        type: BOUNDARY_NODE_FIELD
        components: 3
        safeName: Electric_Field_re,_[V/m] 
        domains:
          - Sur_UNIFPORT_N~{i},  Sur_COAXPORT, Sur_CONDUCTOR, Sur_INTERFACE
        smoothing: 1
        hidden: true
        default: true   
        
      SEfield_im:
        name: SEfield_im
        term:
          - $AfScale~{i} * Im[{e}]
        type: BOUNDARY_NODE_FIELD
        components: 3
        safeName: Electric_Field_im,_[V/m] 
        domains:
          - Sur_UNIFPORT_N~{i},  Sur_COAXPORT, Sur_CONDUCTOR, Sur_INTERFACE
        smoothing: 1
        hidden: true
        default: true      
        
      SurHfield:
        name: SurHfield
        term:
          - $AfScale~{i} * Norm[ {hs} ]
        type: BOUNDARY_NODE_FIELD
        safeName: Magnetic_Field,_[A/m] 
        domains:
          - Sur_UNIFPORT_N~{i},  Sur_COAXPORT, Sur_CONDUCTOR, Sur_INTERFACE
        smoothing: 1
        hidden: true
        default: true
        
      SHfield_re:
        name: SHfield_re
        term:
          - $AfScale~{i} * Re[{hs}]
        type: BOUNDARY_NODE_FIELD
        components: 3
        safeName: Magnetic_Field_re,_[A/m] 
        domains:
          - Sur_UNIFPORT_N~{i},  Sur_COAXPORT, Sur_CONDUCTOR, Sur_INTERFACE
        smoothing: 1
        hidden: true
        default: true   
        
      SHfield_im:
        name: SHfield_im
        term:
          - $AfScale~{i} * Im[{hs}]
        type: BOUNDARY_NODE_FIELD
        components: 3
        safeName: Magnetic_Field_im,_[A/m] 
        domains:
          - Sur_UNIFPORT_N~{i},  Sur_COAXPORT, Sur_CONDUCTOR, Sur_INTERFACE
        smoothing: 1
        hidden: true
        default: true 
        
#############
# Far Field #
#############
   
      NFF:
        name: Far field
        safeName: Far_Field
        description: "far field."
        symbol: E_{far}
        units: V/m
        type: FAR_FIELD
        components: 1
        domains:
          - non_conducting_domain, Sur_CONDUCTOR, Sur_PEC, Sur_COAXPORT, Sur_UNIFPORT_N~{i},  conducting_domain
        smoothing: 1
        EField: NFEField
        HField: NFHField
        hidden: true
        default: true

########################
# Imtermediate globals #
########################
#start key with capital A for these quantities to be estimated before any other!

      AaLoadVoltage~{j}:
        name: LoadVoltage
        safeName: LoadVoltage
        description: "Load voltage"
        term:
          - " {U_port~{j}} "
        type: BOUNDARY_GLOBAL
        components: 1
        domains:
          - Sur_UNIFPORT_N~{j},  Sur_COAXPORT 
        smoothing: 1
        intermediate: true
        needLoop: true
        storeInVariable: true
        hidden: true
        default: true     
        
      AbGamma~{i}:
        name: Reflection Coefficient
        safeName: Reflection_Coefficient
        term:
          - ' {G_port~{i}}'
        type: BOUNDARY_GLOBAL
        domains:
          - Sur_UNIFPORT_N~{i},  Sur_COAXPORT
        smoothing: 1
        intermediate: true
        storeInVariable: true
        hidden: false
        default: true
                       
      AcLoadCurrent~{j}:
        name: Load Current
        safeName: LoadCurrent
        description: "Load current"
        term:
          -  " (2*volt[] - {U_port~{j}}  )/impedance[]    "          
        type: BOUNDARY_GLOBAL
        components: 1
        domains:
          - Sur_UNIFPORT_N~{j},  Sur_COAXPORT
        smoothing: 1
        intermediate: true
        storeInVariable: true
        needLoop: true
        hidden: true
        default: true

      AdLoadImpedance~{j}:
        name: Load Impedance
        safeName: Load_Impedance[Ohm]
        units: \Omega
        term:
          - ' {U_port~{j}}  / $AcLoadCurrent~{j} '
        type: BOUNDARY_GLOBAL
        domains:
          - Sur_UNIFPORT_N~{j},  Sur_COAXPORT
        smoothing: 1
        intermediate: true
        storeInVariable: true
        needLoop: true
        hidden: true
        default: true
              
      AeLoadPower~{j}:
        name: Load Power
        safeName: Load_Power[W]
        units: W
        term:
          - ' Re[{U_port~{j}}  *Conj[$AcLoadCurrent~{j}]] / 2 '
        type: BOUNDARY_GLOBAL
        domains:
          - Sur_UNIFPORT_N~{j},  Sur_COAXPORT
        smoothing: 1
        intermediate: true
        needLoop: true
        storeInVariable: true
        hidden: true
        default: true
        
      AfScale~{j}:
        name: Scale coefficient
        safeName: Scale_Coefficient
        units: '-'
        term:
         - ' 1/Sqrt[volt[]^2 / impedance[] / 2] ' # norming is to 1 W
          # - ' 0.001/Sqrt[volt[]^2 / impedance[] / 2] ' # norming is to 1 mW
        type: BOUNDARY_GLOBAL
        domains:
          - Sur_UNIFPORT_N~{j},  Sur_COAXPORT
        smoothing: 1
        intermediate: true
        needLoop: true
        storeInVariable: true
        hidden: true
        default: true
        
        
###########
# Globals #
###########        
                              
      portImpedance:
        name: Antenna Impedance
        safeName: Antenna_Impedance[Ohm]
        symbol: Z
        units: \Omega
        term:
          - ' Norm[$AdLoadImpedance~{i}] '
        type: BOUNDARY_GLOBAL
        domains:
          - Sur_UNIFPORT_N~{i},  Sur_COAXPORT
        smoothing: 1
        hidden: false
        default: true
        
      portResistance:
        name: Antenna Resistance
        safeName: Antenna_Resistance[Ohm]
        symbol: R
        units: \Omega
        term:
          - ' Re[$AdLoadImpedance~{i}] '
        type: BOUNDARY_GLOBAL
        domains:
          - Sur_UNIFPORT_N~{i},  Sur_COAXPORT
        smoothing: 1
        hidden: false
        default: true
        
      portReactance:
        name: Antenna Reactance
        safeName: Antenna_Reactance[Ohm]
        symbol: X
        units: \Omega
        term:
          - ' Im[$AdLoadImpedance~{i}] '
        type: BOUNDARY_GLOBAL
        domains:
          - Sur_UNIFPORT_N~{i},  Sur_COAXPORT
        smoothing: 1
        hidden: false
        default: true
        
      acceptedPower:
        name: Accepted Power
        safeName: Accepted_Power[W]
        units: W
        term:
          - ' Re[$AeLoadPower~{i}] * $AfScale~{i}^2 '
        type: BOUNDARY_GLOBAL
        domains:
          - Sur_UNIFPORT_N~{i},  Sur_COAXPORT
        smoothing: 1
        hidden: false
        default: true
        
      radiatedPower:
        name: Radiated Power
        safeName: Radiated_Power[W]
        units: W
        type: GLOBAL_EXTERNAL
        domains:
          - Sur_RB
        smoothing: 1
        hidden: false
        default: true
        
      acS11:
        name: S11 Parameter
        safeName: S11[dB]
        units: dB
        term:
          - ' 20 * Log10[{G_port~{i}}]'
        type: BOUNDARY_GLOBAL
        domains:
          - Sur_UNIFPORT_N~{i},  Sur_COAXPORT
        smoothing: 1
        hidden: false
        default: true 

      acS~{j}~{k}:
        name: Sji Parameter
        safeName: Sji[dB]
        units: dB
        term:
          - ' 20 * Log10[{ G_port~{j}~{k} }]'
        term2:
          - ' 20 * Log10[{ U_port~{j}~{k} }]'
        type: BOUNDARY_GLOBAL
        domains:
          - Sur_UNIFPORT_N~{j},  Sur_COAXPORT
        smoothing: 1
        needLoop: true
        hasTwoTerm: true
        hidden: false
        default: true
       
      gamma:
        name: Reflection coefficient
        safeName: Reflection_coefficient
        units: '-'
        term:
          - ' Norm[{G_port~{i}}] '
        type: BOUNDARY_GLOBAL
        domains:
          - Sur_UNIFPORT_N~{i},  Sur_COAXPORT
        smoothing: 1
        hidden: false
        default: true
        
      VSWR:
        name: VSWR
        safeName: VSWR
        units: '-'
        term:
          - ' (1 + Norm[{G_port~{i}}])/(1-Min[0.9999,Norm[{G_port~{i}
          }]])'
        type: BOUNDARY_GLOBAL
        domains:
          - Sur_UNIFPORT_N~{i},  Sur_COAXPORT
        smoothing: 1
        hidden: false
        default: true
                       
      bDielectricLosses:
        name: Dielectric Losses
        safeName: Dielectric_Losses_[W]
        units: W
        term:
          - ' $AfScale~{i}^2/(rmsCoeff[]^2) * Norm[epsilon[] * eps0 * tan_delta[] * {e}* Conj[Complex[0,1]*2*Pi*$Time*FreqFactor*{e}]/Complex[0,1] ]'
        type: INTEGRAL
        domains:
          - non_conducting_domain
        smoothing: 1
        hidden: false
        default: true
        locked: true 


      # cConductorLosses:
        # name: Conductor Losses
        # safeName: Conductor_Losses_[W]
        # units: W
        # term:
          # - ' $AfScale^2/(rmsCoeff[]^2) * Re[Complex[1,1] * Sqrt[ 2 * sigma[] * nu[]*nu0 / (2*Pi* $Time*FreqFactor)]] * SquNorm[Complex[1,1] * Sqrt[ 2 * sigma[] * nu[]*nu0 / (2*Pi* $Time*FreqFactor)] * {e}] '
        # type: BOUNDARY_INTEGRAL
        # domains:
          # - Sur_CONDUCTOR
        # smoothing: 1
        # hidden: false
        # default: true
        # locked: true


      # TotalPower:
        # name: Total Power
        # safeName: Total_Power_[W]
        # units: W
        # term:
          # - '$AfScale^2 *( 0.5 * epsilon[] * eps0 * SquNorm[{e}] + 0.5/nu[] * SquNorm[{d e}] )'
        # type: TOTAL_VALUE
        # domains:
          # - non_conducting_domain, open_air_domain
        # smoothing: 1
        # hidden: false
        # default: true

      # ElectricPower:
        # name: Electric Power
        # safeName: Electric_Power_[W]
        # units: W
        # term:
          # - '$AfScale^2/(rmsCoeff[]^2) *( 0.5 * epsilon[] * eps0 * {e}*Conj[{e}] * (2*Pi*$Time*FreqFactor)  )'
        # type: TOTAL_VALUE
        # domains:
          # - non_conducting_domain, open_air_domain
        # smoothing: 1
        # hidden: false
        # default: true

      # MagneticPower:
        # name: MagneticPower Power
        # safeName: MagneticPower_Power_[W]
        # units: W
        # term:
          # - '$AfScale^2/(rmsCoeff[]^2) *( 0.5 * nu[] * {d e}*Conj[{d e}] / (2*Pi*$Time*FreqFactor) )'
        # type: TOTAL_VALUE
        # domains:
          # - non_conducting_domain, open_air_domain
        # smoothing: 1
        # hidden: false
        # default: true

