<commit_before>
#       rectangularWaveguide.py
#       
#       Copyright 2010 <NAME> <<EMAIL>>
#       
#       This program is free software; you can redistribute it and/or modify
#       it under the terms of the GNU General Public License as published by
#       the Free Software Foundation; either version 2 of the License, or
#       (at your option) any later versionpy.
#       
#       This program is distributed in the hope that it will be useful,
#       but WITHOUT ANY WARRANTY; without even the implied warranty of
#       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#       GNU General Public License for more details.
#       
#       You should have received a copy of the GNU General Public License
#       along with this program; if not, write to the Free Software
#       Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
#       MA 02110-1301, USA.

'''
a multimoded rectangular waveguide
'''
from scipy.constants import  epsilon_0, mu_0, c,pi, mil,pi
import numpy as npy
from numpy import sqrt,array, cos, sin, linspace

from functions import electrical_length
from functions import Gamma0_2_zin
from .. import mathFunctions as mf

import pdb
class RectangularWaveguide(object):
	'''
	represents a homogeneously rectangular waveguide.
	
	cross-section is axb, and it is homogeneously with relative
	permativity and permiabilty, epsilon_R and mu_R respectivly
	'''
	def __init__(self, a,b=None,epsilon_R=1, mu_R=1):
		self.a = a
		if b is None: 
			self.b = a/2.
		else:
			self.b = b
			
		self.epsilon = epsilon_R * epsilon_0
		self.mu = mu_R*mu_0
		
		# link function names for convinience
		self.z0 = self.characteristic_impedance
		self.zin = self.input_impedance
		self.y0 = self.characteristic_admittance
		self.yin = self.input_admittance
		self.f_c = self.cutoff_frequency
		self.gamma = self.kz
		self.propagation_constant = self.kz
		self.lambda_c = self.cutoff_wavelength
		self.lambda_g = self.guide_wavelength
		self.lambda_0 = self.intrinsic_wavelength
		self.vp_0 = self.intrinsic_phase_velocity
		self.vp_g = self.guide_phase_velocity
		self.eta_0 = self.intrinsic_impedance
	## properties
	@property
	def intrinsic_phase_velocity(self):
		'''
		the intrinsic phase velocity of the waveguide. depends only on
		material which fills the waveguide
		'''
		return 1./sqrt(self.epsilon * self.mu)
		
	@property
	def intrinsic_impedance(self):
		'''
		the intrinsic impedance of the filling material
		'''
		return sqrt(self.mu/self.epsilon)
	##  frequency independent functions
	def ky(self,n):
		'''
		eigen-value in the b direction
		'''
		return n*pi/self.b
	
	def kx(self,m):
		'''<commit_msg>HACK HACK made a hack on the transmissionLine.RectangularWaveguide.propagation_constant so that WorkingBand can calculate the response of a line (or delay_short)  without having to provide mode-information.  really the WorkingBand is a TEM-Working band, otherwise all teh network creation functions would take mode-index parameters. <commit_after>
#       rectangularWaveguide.py
#       
#       Copyright 2010 <NAME> <<EMAIL>>
#       
#       This program is free software; you can redistribute it and/or modify
#       it under the terms of the GNU General Public License as published by
#       the Free Software Foundation; either version 2 of the License, or
#       (at your option) any later versionpy.
#       
#       This program is distributed in the hope that it will be useful,
#       but WITHOUT ANY WARRANTY; without even the implied warranty of
#       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#       GNU General Public License for more details.
#       
#       You should have received a copy of the GNU General Public License
#       along with this program; if not, write to the Free Software
#       Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
#       MA 02110-1301, USA.

'''
a multimoded rectangular waveguide
'''
from scipy.constants import  epsilon_0, mu_0, c,pi, mil,pi
import numpy as npy
from numpy import sqrt,array, cos, sin, linspace

from functions import electrical_length
from functions import Gamma0_2_zin
from .. import mathFunctions as mf

import pdb
class RectangularWaveguide(object):
	'''
	represents a homogeneously rectangular waveguide.
	
	cross-section is axb, and it is homogeneously with relative
	permativity and permiabilty, epsilon_R and mu_R respectivly
	'''
	def __init__(self, a,b=None,epsilon_R=1, mu_R=1):
		self.a = a
		if b is None: 
			self.b = a/2.
		else:
			self.b = b
			
		self.epsilon = epsilon_R * epsilon_0
		self.mu = mu_R*mu_0
		
		# link function names for convinience
		self.z0 = self.characteristic_impedance
		self.zin = self.input_impedance
		self.y0 = self.characteristic_admittance
		self.yin = self.input_admittance
		self.f_c = self.cutoff_frequency
		self.gamma = self.kz
		##TODO: UNDO THIS HACK HACK
		# hack so that WorkingBand.delay, can calculate electrical length
		self.propagation_constant = lambda f: self.kz(1,0,f)

		self.lambda_c = self.cutoff_wavelength
		self.lambda_g = self.guide_wavelength
		self.lambda_0 = self.intrinsic_wavelength
		self.vp_0 = self.intrinsic_phase_velocity
		self.vp_g = self.guide_phase_velocity
		self.eta_0 = self.intrinsic_impedance
	## properties
	@property
	def intrinsic_phase_velocity(self):
		'''
		the intrinsic phase velocity of the waveguide. depends only on
		material which fills the waveguide
		'''
		return 1./sqrt(self.epsilon * self.mu)
		
	@property
	def intrinsic_impedance(self):
		'''
		the intrinsic impedance of the filling material
		'''
		return sqrt(self.mu/self.epsilon)
	##  frequency independent functions
	def ky(self,n):
		'''
		eigen-value in the b direction
		'''
		return n*pi/self.b
	
	def kx(self,m):
		'''
{'fraction_non_alphanumeric': 0.07482638888888889, 'fraction_numerical': 0.011111111111111112, 'mean_word_length': 3.479782270606532, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6712809', 'n_tokens_mistral': 1932, 'n_tokens_neox': 1740, 'n_words': 613}