Drill Shaft Communication

! APMonitor Modeling Language
! http://www.apmonitor.com

! The principal input to the model is the voltage to the motor.
! Parameters include resistance (ohm), winding inductance (henrys)
Model pipe
  Parameters
    ! communication parameters
    v_in = 0      ! input voltage (Volt)
    R = 0.1       ! resistance (Ohm)
    L = 1e-5      ! inductance (Henry)
    C = 1e-8      ! capacitance (Farad)

    t[1] = 23     ! temperature in first pipe segment (°C)
    t[2:10] = t[1:9] + 10  ! temperature increases by 5°C with each segment  

    n[1:10] = 100 ! number of windings on each pipe segment
                  ! can modify for different number of windings on each end
  End Parameters

  Variables
    i[1:10] = 0   ! current (Amps)
    v[1:10] = 0   ! voltage (Volt)
  End Variables

  Intermediates
    ! loss across pipe connections (dB)
    ! linear correlation (20°C = 0.5 dB, 120°C = 1.5 dB)
    dB[1:10] = (t[1:10] - 20) * (1.5-0.5)/(120-20) + 0.5

    ! inductor to inductor transfer efficiency
    eff[1:10] = 10^(-db[1:10]/20), >=0, <=1
    eff_avg[1:9] = (eff[1:9] + eff[2:10]) / 2
  End Intermediates

  Equations
    ! input voltage effect on current in 1st pipe
    L*$i[1] = -R*i[1] + v_in

    ! current dynamics in each segment
    L*$i[2:10] = -R*i[2:10] + (n[2:10]/n[1:9]) * v[1:9] * eff_avg[1:9]

    ! voltage dynamics from capacitance
    C * $v[1:10] = i[1:10] - v[1:10]/R
  End Equations

End Model