• Main Page
  • Related Pages
  • Classes
  • Files
  • File List
  • File Members

ocsOptFiberLocalError10July2009.hh

Go to the documentation of this file.
00001 // $Id: ocsOptFiberLocalError.hh,v 1.8 2008/08/08 02:21:34 zweck Exp $
00002 
00003 //###################################################################
00004 //
00005 //           Optical Communication Systems Simulator
00006 //
00007 //       Copyright (2000):
00008 //       Optical Fiber Communications Laboratory (OFCL)
00009 //       Computer Science & Electrical Engineering Department (CSEE)
00010 //       University of Maryland Baltimore County (UMBC)
00011 //
00012 //###################################################################
00013 
00014 #ifndef _OCS_OPT_FIBER_LOCAL_ERROR_HH_
00015 #define _OCS_OPT_FIBER_LOCAL_ERROR_HH_
00016 
00017 #include "ocsOptSignal.hh"
00018 #include "ocsRamanAmp.hh"
00019 
00020 
00022 
00028 enum typeRamanAmplification { NO_RAMAN = 0, 
00029                               SIMPLE_RAMAN = 1, 
00030                               FULL_RAMAN = 2 }; 
00031 
00032 
00034 
00060 enum typeFiberLossGain {LOSSY_FIBER = 0,
00061                         FIBER_AMPLIFIER = 1};
00062 
00097 enum typeFiberAmplifierNoise {FIBER_AMP_NOISE_OFF = 0,
00098                               FIBER_AMP_NOISE_GAUSSIAN_WHITE = 2};
00099 
00100 
00200 enum typeFiberAmplifierGain {FIBER_AMP_UNSATURATED_FLAT_GAIN = 0,
00201                              FIBER_AMP_SATURABLE_PARABOLIC_GAIN = 1};   
00202 
00204 
00256 enum typeStepSizes { LOCAL_ERROR_3RD = 1, 
00257                      LOCAL_ERROR_2ND = 2, 
00258                      WALK_OFF = 3,
00259                      CONSTANT = 4 };
00260 
00263 
00264 enum { APPLY_ONCE = 0, APPLY_TWICE = 1 };
00265 
00536 class OptFiberLocalError
00537 {
00538 
00539  public:
00540 
00542 
00543   OptFiberLocalError(string InFileName, OptSignal *oOptSignal, RanNumGen *RNG2,
00544                     string Job2);
00545 
00546   void SetRamanAmpPointer(RamanAmp * oRaman2);
00547 
00549 
00550  ~OptFiberLocalError(void);
00551 
00553 
00554  void Propagate(double * PropagatedLength,int * ZStepNum);
00555 
00558 
00559  void PropagateWithRaman(double * PropagatedLength,
00560                          int * ZStepNum,
00561                          double  RamanStartingLength2);
00562  
00563  string WriteTypeSolver(void);
00564  string WriteTypeStepSizes(void); 
00565  string WriteTypeFiberLossGain(void);
00566  string WriteTypeFiberAmplifierNoise(void);
00567  string WriteTypeFiberAmplifierGain(void);
00568 
00569  void OpenStepSizesFile(string StepSizesFileName,int Mode);
00570  void WriteStepSizes(double PropagatedLength);
00571  void WriteAveragePowerdBm(double PropagatedLength2);
00572 
00573  // Get methods
00574 
00575  double GetFirstOrderDispersion() {return  FstOrDispFiber;};
00576  double GetSecondOrderDispersion() {return  SndOrDispFiber;};
00577  double GetFiberLength() {return LengthFiber;};
00578  double GetNepperAttenuationFiber() {return NepperAttenuationFiber;};
00579  double GetNonLinIndexFiber() {return NonLinIndexFiber;};
00580  double GetGamma() {return gamma;};
00581  double GetDeltaZ() {return DeltaZ;}; 
00582  int GetNumStepsBetweenScatterings() {return NumStepsBetweenScatterings;};
00583 
00584  void SetNumStepsBetweenScatterings(int value) 
00585         {NumStepsBetweenScatterings = value;
00586          SetFiberLengthsForPMD(); };
00587 
00589 
00590   double GetDispersion(double Wavelength);
00591 
00592  // Set methods
00593 
00594  void SetTypeStepSizes(int TypeStepSizes2);
00595  void SetWalkOffParameter(double WalkOffParameter2); 
00596  void SetConstantDeltaZ(double DeltaZValue);
00597 
00598  // void SetNumStepsBetweenScatterings(int Value);
00599 
00600  void SetOutputStepSizesFlag(int OutputStepSizesFlag2);
00601  void SetRelativeErrorGoal(double RelativeErrorGoal2);
00602 
00603 
00608  void SetFstOrDispFiber(double FstOrDispFiber2);
00609 
00614  void SetSndOrDispFiber(double SndOrDispFiber2);
00615  void RecoverSndOrDispFiber();
00616 
00617  void SetDispersion(double DispersionFiberRefWavelength,
00618                     double DispSlopeFiberRefWavelength); // s/m^2 and s/m^3
00619 
00624  void SetGammaFiber(double gamma2);
00625  void RecoverGammaFiber();
00626 
00629 
00630  void SetAttenuationdB(double AttenuationFiber2);
00631 
00635  
00636  void SetNepperAttenuation(double NepperAttenuation2);
00637 
00638 
00640 
00641  void SetFiberAmplifierUnsaturatedNepperGain(
00642            double FiberAmplifierUnsaturatedNepperGain2);
00643 
00649 
00650  void ComputeDeltaZMax(void);
00651 
00652  void SetWriteAveragePowerdBmFlag(int Value);
00653 
00654   void SetWritePulseWidthFlag(int Value) {WritePulseWidthFlag = Value;};
00655 
00656   void SetFiberLength(double Value);
00657   void SetScatteringStepSize(double Value);
00658 
00659   // ####### Methods related to Manakov-PMD equation ######
00660 
00661   void GetNewFiberRealization(void);
00662   void SetFiberRealization(int SectionNumber, 
00663                            double Theta2, double Phi2, double Psi2);
00664 
00665   void ApplyPMDCompleteScatteringFreqDomainOperator(
00666                        int ScatteringSectionIndex);
00667   
00668   void ComputeEulerMatrixAndUpdateOutputPDVector(int ScatteringSectionIndex);
00669 
00670   void GetEulerMatrix(double theta,double phi,double psi);
00671 
00672   void SetFiberLengthsForPMD(void);
00673 
00674   void SetMeanDGDPerSqrtLength(double MeanDGDPerSqrtLength2);
00675   void SetPMD(double PMD2);
00676   double GetFreqDerivativeOfBirefringence(void);
00677 
00678   double GetDGD(void);  
00679  
00680   void PropagateOutputPDVector(double Freq,
00681                                 double theta, double phi, double psi);
00682 
00683   double GetExpectedDGD() 
00684              {return sqrt(8./(3.*pi)*LengthFiber)*PMD; };
00685   double GetExpectedSndOrderDGD() 
00686              {return sq(GetExpectedDGD())/sqrt(3.); };
00687   double GetMeanDGD_SqrtLength(void) 
00688              {return sqrt(1e3)/1e-12*MeanDGDPerSqrtLength;};
00689 
00690   // JZ Commented out 
00691    void UpdateJonesMatrixAfterBiregringence(double StepSizeZ);
00692 
00693   // ########## PUBLIC DATA #####################
00694   
00695 
00696 public:
00697 
00698   RamanAmp * oRaman;
00699 
00700   // ########## PRIVATE METHODS ####################
00701 
00702  private:
00703 
00704   // Private Methods
00705 
00706  void PropagateWithPMD(double * PropagatedLength,
00707                                            int * ZStepNum);
00708 
00709  void PropagateWithoutPMD(double * PropagatedLength,
00710                                            int * ZStepNum);
00711 
00712  void PropagateLocalError(double * PropagatedLength, int * ZStepNum);
00713 
00714 
00715  void PropagateConstStepSizeOrWalkOff(double * PropagatedLength,
00716                                         int * ZStepNum);
00717 
00718 
00719  void ResetVolatileVariables(void);
00720 
00721  void inline UpdateFreq(void);
00722  void inline UpdateTime(void);
00723 
00724  void ComputeWalkOffStepSize(void);
00725 
00726  void ComputeFreqDomainOperator(double StepSizeZ);
00727  void ApplyFreqDomainOperator(bool ApplyTwiceFlag);
00728  void ApplyRamanOperator(double CurrentZValueWithinFiber2,double ZStep2);
00729  void ApplyTimeDomainOperator(double StepSizeZ);
00730 
00731  double ComputeMaxPower(void);
00732 
00733  void CopyFftMatricesFreqData(fftMatrices * OrigData,fftMatrices * CopyOfData);
00734 
00735  double ComputeThirdOrderSolutionAndRelativeError(void);
00736  double ComputeThirdOrderSolutionAndRelativeErrorOLD(void);
00737 
00738   // AccumulatedFirstOrderDispersion is a data member in the 
00739   // OptSignal class which keeps track of the total dispersion
00740   // (beta'') in s^2 which the signal has experienced.
00741   // The UpdateAccumulatedFirstOrderDispersion is called each z-step.
00742 
00743  void UpdateAccumulatedFirstOrderDispersion(double StepSize);
00744  void UpdateAccumulatedSecondOrderDispersion(double StepSize);
00745 
00749 
00750  void FiberAmplifierComputeSaturableGain(void);
00751 
00756 
00769   void FiberAmplifierComputeNoiseAmplitudeFactor(double StepSize);
00770 
00773 
00774   void FiberAmplifierAddMonteCarloNoise(double StepSize);
00775 
00776   void AllocateMemoryForEulerAngles(void);
00777 
00778   // Private Raman Methods
00779   
00780   void ApplySimpleRamanOperator(double CurrentZValueWithinFiber2,
00781                                 double ZStep2);
00782 
00783   void ApplyFullRamanOperator(double CurrentZValueWithinFiber2,double ZStep2);
00784 
00785   // ########## PRIVATE DATA ######################
00786 
00787   // Private Data
00788 
00789  ofstream StepSizesFile;
00790 
00791  int OutputStepSizesFlag;
00792  int StepSizesFileMode;
00793  string Job;
00794 
00796   /* Options are 
00797      -# SCALAR_NLS = 1: The PDE is the scalar nonlinear Schroedinger equation
00798         as used in optical communications. This code can be run with or without
00799         the 8/9-ths factor in the Kerr nonlinearity term. This factor should
00800         be included when using a scalar PDE to
00801         model noise-free systems in the limit as the birefringence
00802         goes to zero, or more precsiely in the limit that the characteristic 
00803         length scale for PMD is longer than system length (See CRM's paper
00804         J Eng Math, Eqn 68).
00805      -# VECTOR_MANAKOV_PMD = 2: The PDE is the vector Manakov equation
00806         as in CRM's J Eng Math, Eqn (67), in the case that there is no linear
00807         PMD term and no nonlinear PMD. This equation is appropriate for
00808         simulations with noise when the characteristic 
00809         length scale for PMD is longer than system length.
00810      -# VECTOR_MANAKOV_NO_PMD = 3: The PDE is the vector Manakov equation
00811         as in CRM's J Eng Math, Eqn (67) with linear PMD (but not nonlinear
00812         PMD term). Includes the birefringence and random scattering on 
00813         the Poincare sphere.
00814   */
00815 
00816   typeSolver TypeSolver;
00817 
00818   typeStepSizes TypeStepSizes; // This variable used to be called
00819                                // TypeAlgorithm
00820 
00821 
00822   typeFiberLossGain TypeFiberLossGain;
00823 
00824   typeFiberAmplifierNoise TypeFiberAmplifierNoise;
00825 
00828 
00829   double FiberAmplifierSpontaneousEmissionFactor;
00830 
00832 
00848   double FiberAmplifierNoiseMaxStepSizeFactor;
00849 
00851   /*
00852 
00853     Used when TypeFiberLossGain = FIBER_AMPLIFIER and 
00854       TypeFiberAmplifierGain == FIBER_AMP_SATURABLE_PARABOLIC_GAIN
00855 
00856     The step size is chosen to gaurantee that
00857 
00858     Power(z+delta_z)/Power(z) < FiberAmplifierGainSaturationMaxGainPerStep
00859    
00860     Note that this gain is specified on a linear scale.
00861 
00862     Default value is 1.01
00863 
00864     This ensures that power is correctly computed in calculation of saturable
00865     gain.
00866 
00867     \sa enum typeFiberAmplifierGain.
00868 
00869     \sa FiberAmplifierNoiseMaxStepSizeFactor
00870 
00871   */ 
00872 
00873   double FiberAmplifierGainSaturationMaxGainPerStep;
00874 
00876 
00877   double FiberAmplifierNoiseAmplitudeFactor;
00878 
00880 
00881   typeFiberAmplifierGain TypeFiberAmplifierGain;
00882 
00885 
00886   double FiberAmplifierParabolicGainCoefficient;
00887 
00890 
00891   double FiberAmplifierUnsaturatedNepperGain;
00892 
00895 
00896   double FiberAmplifierSaturationEnergy;
00897 
00899 
00900   double FiberAmplifierSaturableGainPerLength;
00901 
00905 
00907 
00918   double FastSaturableAbsorptionCoefficient;
00919 
00922 
00923   bool DoFastSaturableAbsorptionFlag;
00924 
00926 
00930   bool DoTimeOperatorExactlyFlag;
00931 
00933 
00941   bool FreqDomainOperatorValid;
00942 
00960  int ScalarSolverEightNinthsFlag; 
00961 
00962  OptSignal * oOptSignal;
00963  RanNumGen * RNG;
00964  cfftw *fft;
00965  fftMatrices sfftM;  
00966 
00967  cplx * FreqDomainOperatorX;
00968  cplx * FreqDomainOperatorY;
00969 
00970  cplx * SqFreqDomainOperatorX;
00971  cplx * SqFreqDomainOperatorY;
00972 
00973   
00974  fftMatrices sfftM_Start;
00975  fftMatrices sfftM_Coarse;
00976  
00977  double LengthFiber;
00978  
00979  double RamanStartingLength;
00980  double PropagatedLengthStartFiber;
00981  int NumStepsBetweenScatterings; // For const step size second order algorithm
00982 
00983   double ReferenceFreq;
00984   double ReferenceWavelength;
00985 
00986 
00987   double DispersionFiberCenterWavelength; // s/(m^2)
00988   double DispSlopeFiberCenterWavelength; // s/(m^3)
00989 
00992 
00993  bool SetFstSndOrDispDirectlyFlag; 
00994 
00995  double FstOrDispFiber; // s^2/m
00996  double SndOrDispFiber;
00997  double SndOrDispFiber_Save;
00998  double NonLinIndexFiber;
00999 
01002 
01003  int    WithNonLin;                   
01004 
01005  double EffectAreaFiber;  
01006 
01008 
01022  double AttenuationFiber;      
01023 
01027 
01028  double NepperAttenuationFiber;
01029 
01030   typeRamanAmplification TypeRamanAmplification;
01031 
01032 // Variables for simple raman model
01033 
01034   double RamanOnOffGaindB;
01035   double NepperRamanGain;
01036   double NepperRamanPumpLoss;
01037 
01038  double CenterFreq;      
01039  int    qtPoints;
01040  double DeltaFreq;     
01041  double gamma;
01042  double gamma_Save;
01043 
01044  double CurrentZValueWithinFiber; 
01045    // Ranges from 0 to LengthFiber during
01046   // course of propagation within the current fiber
01047 
01049 
01054  double DeltaZ;
01055  double DeltaZMaxInfile, DeltaZMax;
01056 
01058 
01059  double DeltaZInitial;
01060 
01061  bool InitializedDeltaZInitialFlag;
01062  
01063  double WalkOffStepSize;
01064  double WalkOffLastStepSize;
01065  int WalkOffNumSteps;
01066  double WalkOffParameter;
01067  
01068  double MaxPower;
01069 
01070  double FWHM_Pulse;
01071 
01072  bool TimeDataValid;
01073  bool FreqDataValid;
01074 
01075  double RelativeError;
01076  double RelativeErrorGoal;
01077 
01078  int LocalErrorFreqLimit;
01079 
01080  int WriteAveragePowerdBmFlag;
01081  int WritePulseWidthFlag;
01082  
01083    // ####### Variables related to Manakov-PMD equation ######
01084 
01085   double *OutputPDVector;
01086   double *InputPDVector;
01087   
01088   // Variables related to birefringence strength
01089 
01090  double PMD;
01091  double MeanDGDPerSqrtLength;
01092 
01093  // Variables related to random rotation of axes of birefringence
01094 
01095  double ScatteringStepSize;
01096  cplx EulerMatrix[2][2];
01097 
01098   int NumberScatterings;
01099   double TotalLengthFiber;
01100   double LengthFiberExceptLast, LengthFiberLast;
01101 
01102   // Arrays for length NumberScatterings for the Euler angles
01103 
01104   double * Theta;
01105   double * Phi;
01106   double * Psi;
01107 
01108  double *PDVectorHai;             //added by Hai 8/14/03
01109  
01110  
01111  cplx *JonesMatrix;   //added by Hai 7-1-03
01112  int NumberOfChannels;  //added by Hai 7-1-03
01113  double *FreqChannels;   //added by Hai 7-1-03
01114 
01115 
01116 
01117 
01118 };
01119 
01120 #endif /* _OCS_OPT_FIBER_LOCAL_ERROR_HH_ */
01121 
01122 
01123 
01124 
01125 

Generated on Fri Jul 2 2010 12:57:47 for OCS by  doxygen 1.7.1