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

ocsOptFiberLocalErrorNew.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 ComputeDispersionOperator(double StepSizeZ);
00727  void ApplyDispersionOperator(bool ApplyTwiceFlag);
00728  void ApplySaturableParabolicGainOperator(double StepSizeZ);
00729  void ApplyFreqDomainOperator(bool ApplyDispersionTwiceFlag,
00730                               double GainSatStepSizeZ);
00731 
00732  void ApplyRamanOperator(double CurrentZValueWithinFiber2,double ZStep2);
00733  void ApplyTimeDomainOperator(double StepSizeZ);
00734 
00735  double ComputeMaxPower(void);
00736 
00737  void CopyFftMatricesFreqData(fftMatrices * OrigData,fftMatrices * CopyOfData);
00738 
00739  double ComputeThirdOrderSolutionAndRelativeError(void);
00740  double ComputeThirdOrderSolutionAndRelativeErrorOLD(void);
00741 
00742   // AccumulatedFirstOrderDispersion is a data member in the 
00743   // OptSignal class which keeps track of the total dispersion
00744   // (beta'') in s^2 which the signal has experienced.
00745   // The UpdateAccumulatedFirstOrderDispersion is called each z-step.
00746 
00747  void UpdateAccumulatedFirstOrderDispersion(double StepSize);
00748  void UpdateAccumulatedSecondOrderDispersion(double StepSize);
00749 
00753 
00754  void FiberAmplifierComputeSaturableGain(void);
00755 
00759 
00760  double FiberAmplifierComputeSaturableGainForHeunsMethod(bool FirstStep);
00761 
00764 
00765  double FiberAmplifierGetEnergyForHeunsMethod(bool FirstStep);
00766 
00771 
00784   void FiberAmplifierComputeNoiseAmplitudeFactor(double StepSize);
00785 
00788 
00789   void FiberAmplifierAddMonteCarloNoise(double StepSize);
00790 
00791   void AllocateMemoryForEulerAngles(void);
00792 
00793   // Private Raman Methods
00794   
00795   void ApplySimpleRamanOperator(double CurrentZValueWithinFiber2,
00796                                 double ZStep2);
00797 
00798   void ApplyFullRamanOperator(double CurrentZValueWithinFiber2,double ZStep2);
00799 
00800   // ########## PRIVATE DATA ######################
00801 
00802   // Private Data
00803 
00804  ofstream StepSizesFile;
00805 
00806  int OutputStepSizesFlag;
00807  int StepSizesFileMode;
00808  string Job;
00809 
00810  typeSimulation TypeSimulation;
00811 
00813   /* Options are 
00814      -# SCALAR_NLS = 1: The PDE is the scalar nonlinear Schroedinger equation
00815         as used in optical communications. This code can be run with or without
00816         the 8/9-ths factor in the Kerr nonlinearity term. This factor should
00817         be included when using a scalar PDE to
00818         model noise-free systems in the limit as the birefringence
00819         goes to zero, or more precsiely in the limit that the characteristic 
00820         length scale for PMD is longer than system length (See CRM's paper
00821         J Eng Math, Eqn 68).
00822      -# VECTOR_MANAKOV_PMD = 2: The PDE is the vector Manakov equation
00823         as in CRM's J Eng Math, Eqn (67), in the case that there is no linear
00824         PMD term and no nonlinear PMD. This equation is appropriate for
00825         simulations with noise when the characteristic 
00826         length scale for PMD is longer than system length.
00827      -# VECTOR_MANAKOV_NO_PMD = 3: The PDE is the vector Manakov equation
00828         as in CRM's J Eng Math, Eqn (67) with linear PMD (but not nonlinear
00829         PMD term). Includes the birefringence and random scattering on 
00830         the Poincare sphere.
00831   */
00832 
00833   typeSolver TypeSolver;
00834 
00835   typeStepSizes TypeStepSizes; // This variable used to be called
00836                                // TypeAlgorithm
00837 
00838 
00839   typeFiberLossGain TypeFiberLossGain;
00840 
00841   typeFiberAmplifierNoise TypeFiberAmplifierNoise;
00842 
00845 
00846   double FiberAmplifierSpontaneousEmissionFactor;
00847 
00849 
00865   double FiberAmplifierNoiseMaxStepSizeFactor;
00866 
00868   /*
00869 
00870     Used when TypeFiberLossGain = FIBER_AMPLIFIER and 
00871       TypeFiberAmplifierGain == FIBER_AMP_SATURABLE_PARABOLIC_GAIN
00872 
00873     The step size is chosen to gaurantee that
00874 
00875     Power(z+delta_z)/Power(z) < FiberAmplifierGainSaturationMaxGainPerStep
00876    
00877     Note that this gain is specified on a linear scale.
00878 
00879     Default value is 1.01
00880 
00881     This ensures that power is correctly computed in calculation of saturable
00882     gain.
00883 
00884     \sa enum typeFiberAmplifierGain.
00885 
00886     \sa FiberAmplifierNoiseMaxStepSizeFactor
00887 
00888   */ 
00889 
00890   double FiberAmplifierGainSaturationMaxGainPerStep;
00891 
00893 
00894   double FiberAmplifierNoiseAmplitudeFactor;
00895 
00897 
00898   typeFiberAmplifierGain TypeFiberAmplifierGain;
00899 
00902 
00903   double FiberAmplifierParabolicGainCoefficient;
00904 
00907 
00908   double FiberAmplifierUnsaturatedNepperGain;
00909 
00912 
00913   double FiberAmplifierSaturationEnergy;
00914 
00916 
00917   double FiberAmplifierSaturableGainPerLength;
00918 
00922 
00924 
00935   double FastSaturableAbsorptionCoefficient;
00936 
00939 
00940   bool DoFastSaturableAbsorptionFlag;
00941 
00943 
00947   bool DoTimeOperatorExactlyFlag;
00948 
00950 
00958   bool DispersionOperatorValid;
00959 
00977  int ScalarSolverEightNinthsFlag; 
00978 
00979  OptSignal * oOptSignal;
00980  RanNumGen * RNG;
00981  cfftw *fft;
00982  fftMatrices sfftM;  
00983 
00984  cplx * FreqDomainOperatorX;
00985  cplx * FreqDomainOperatorY;
00986 
00987  cplx * SqFreqDomainOperatorX;
00988  cplx * SqFreqDomainOperatorY;
00989 
00990   
00991  fftMatrices sfftM_Start;
00992  fftMatrices sfftM_Coarse;
00993  cplx * LaserWorkX;
00994  cplx * LaserWorkY;
00995 
00996 
00997  double LengthFiber;
00998  
00999  double RamanStartingLength;
01000  double PropagatedLengthStartFiber;
01001  int NumStepsBetweenScatterings; // For const step size second order algorithm
01002 
01003   double ReferenceFreq;
01004   double ReferenceWavelength;
01005 
01006 
01007   double DispersionFiberCenterWavelength; // s/(m^2)
01008   double DispSlopeFiberCenterWavelength; // s/(m^3)
01009 
01012 
01013  bool SetFstSndOrDispDirectlyFlag; 
01014 
01015  double FstOrDispFiber; // s^2/m
01016  double SndOrDispFiber;
01017  double SndOrDispFiber_Save;
01018  double NonLinIndexFiber;
01019 
01022 
01023  int    WithNonLin;                   
01024 
01025  double EffectAreaFiber;  
01026 
01028 
01042  double AttenuationFiber;      
01043 
01047 
01048  double NepperAttenuationFiber;
01049 
01050   typeRamanAmplification TypeRamanAmplification;
01051 
01052 // Variables for simple raman model
01053 
01054   double RamanOnOffGaindB;
01055   double NepperRamanGain;
01056   double NepperRamanPumpLoss;
01057 
01058  double CenterFreq;      
01059  int    qtPoints;
01060  double DeltaFreq;     
01061  double gamma;
01062  double gamma_Save;
01063 
01064  double CurrentZValueWithinFiber; 
01065    // Ranges from 0 to LengthFiber during
01066   // course of propagation within the current fiber
01067 
01069 
01074  double DeltaZ;
01075  double DeltaZMaxInfile, DeltaZMax;
01076 
01078 
01079  double DeltaZInitial;
01080 
01081  bool InitializedDeltaZInitialFlag;
01082  
01083  double WalkOffStepSize;
01084  double WalkOffLastStepSize;
01085  int WalkOffNumSteps;
01086  double WalkOffParameter;
01087  
01088  double MaxPower;
01089 
01090  double FWHM_Pulse;
01091 
01092  bool TimeDataValid;
01093  bool FreqDataValid;
01094 
01095  double RelativeError;
01096  double RelativeErrorGoal;
01097 
01098  int LocalErrorFreqLimit;
01099 
01100  int WriteAveragePowerdBmFlag;
01101  int WritePulseWidthFlag;
01102  
01103    // ####### Variables related to Manakov-PMD equation ######
01104 
01105   double *OutputPDVector;
01106   double *InputPDVector;
01107   
01108   // Variables related to birefringence strength
01109 
01110  double PMD;
01111  double MeanDGDPerSqrtLength;
01112 
01113  // Variables related to random rotation of axes of birefringence
01114 
01115  double ScatteringStepSize;
01116  cplx EulerMatrix[2][2];
01117 
01118   int NumberScatterings;
01119   double TotalLengthFiber;
01120   double LengthFiberExceptLast, LengthFiberLast;
01121 
01122   // Arrays for length NumberScatterings for the Euler angles
01123 
01124   double * Theta;
01125   double * Phi;
01126   double * Psi;
01127 
01128  double *PDVectorHai;             //added by Hai 8/14/03
01129  
01130  
01131  cplx *JonesMatrix;   //added by Hai 7-1-03
01132  int NumberOfChannels;  //added by Hai 7-1-03
01133  double *FreqChannels;   //added by Hai 7-1-03
01134 
01135 
01136 
01137 
01138 };
01139 
01140 #endif /* _OCS_OPT_FIBER_LOCAL_ERROR_HH_ */
01141 
01142 
01143 
01144 
01145 

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