module EMWave
module InterfaceHelper
include Math
def te_reflection( ita1, ita2, thita1, thita2 )
thita1 = angle2arc thita1
thita2 = angle2arc thita2
( ita2 * cos(thita1) - ita1 * cos(thita2) ) / ( ita2 * cos(thita1) + ita1 * cos(thita2) )
end
def te_transmission( ita1, ita2, thita1, thita2 )
thita1 = angle2arc thita1
thita2 = angle2arc thita2
( 2 * ita2 * cos(thita1) ) / ( ita2 * cos(thita1) + ita1 * cos(thita2) )
end
def tm_reflection( ita1, ita2, thita1, thita2 )
thita1 = angle2arc thita1
thita2 = angle2arc thita2
( ita2 * cos(thita2) - ita1 * cos(thita1) ) / ( ita2 * cos(thita2) + ita1 * cos(thita1) )
end
def tm_transmission( ita1, ita2, thita1, thita2 )
thita1 = angle2arc thita1
thita2 = angle2arc thita2
( 2 * ita2 * cos(thita1) ) / ( ita2 * cos(thita2) + ita1 * cos(thita1) )
end
def transmit_angle( n1, n2, incident_angle )
asin( ( n1 / n2 ) * sin( angle2arc ( incident_angle ) ) )
end
end
class Interface
include Math
include InterfaceHelper
attr_accessor :eps_r1, :eps_r2, :mu_r1, :mu_r2
def initialize( params = {} )
@eps_r1 = params[:eps_r1] ? params[:eps_r1] : 1
@eps_r2 = params[:eps_r2] ? params[:eps_r2] : 1
@mu_r1 = ( params[:mu_r1] or 1 )
@mu_r2 = ( params[:mu_r2] or 1 )
end
# return impedance of medium one
#
def ita1
120 * PI * sqrt( @mu_r1 / @eps_r1 )
end
# return impedance of medium two
#
def ita2
120 * PI * sqrt( @mu_r2.to_f / @eps_r2 )
end
def n1
return @n1 if @n1
@n1 = sqrt(@eps_r1 * @mu_r1)
end
def n2
return @n2 if @n2
@n2 = sqrt(@eps_r2 * @mu_r2)
end
# return reflection of TE mode / perpendicular polarization / horization polarization
#
def te_reflection_at( incident_angle )
te_reflection( ita1, ita2, incident_angle, transmit_angle( n1, n2, incident_angle ) )
end
def te_transmission_at( incident_angle )
te_transmission( ita1, ita2, incident_angle, transmit_angle( n1, n2, incident_angle ) )
end
def tm_reflection_at( incident_angle )
tm_reflection( ita1, ita2, incident_angle, transmit_angle(n1, n2, incident_angle) )
end
def tm_transmission_at( incident_angle )
tm_transmission( ita1, ita2, incident_angle, transmit_angle(n1, n2, incident_angle) )
end
def reflection_axial_ratio( incident_angle )
20 * log( te_reflection_at(incident_angle).abs / tm_reflection_at(incident_angle).abs )
end
def transmission_axial_ratio( incident_angle )
20 * log( te_transmission_at(incident_angle).abs / tm_transmission_at(incident_angle).abs ).abs
end
end
end
module Math
def angle2arc(angle)
angle * PI / 180
end
def arc2angle(arc)
arc * 180 / PI
end
end