Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
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
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
00593
00594 void SetTypeStepSizes(int TypeStepSizes2);
00595 void SetWalkOffParameter(double WalkOffParameter2);
00596 void SetConstantDeltaZ(double DeltaZValue);
00597
00598
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);
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
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
00691 void UpdateJonesMatrixAfterBiregringence(double StepSizeZ);
00692
00693
00694
00695
00696 public:
00697
00698 RamanAmp * oRaman;
00699
00700
00701
00702 private:
00703
00704
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
00739
00740
00741
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
00779
00780 void ApplySimpleRamanOperator(double CurrentZValueWithinFiber2,
00781 double ZStep2);
00782
00783 void ApplyFullRamanOperator(double CurrentZValueWithinFiber2,double ZStep2);
00784
00785
00786
00787
00788
00789 ofstream StepSizesFile;
00790
00791 int OutputStepSizesFlag;
00792 int StepSizesFileMode;
00793 string Job;
00794
00796
00797
00798
00799
00800
00801
00802
00803
00804
00805
00806
00807
00808
00809
00810
00811
00812
00813
00814
00815
00816 typeSolver TypeSolver;
00817
00818 typeStepSizes TypeStepSizes;
00819
00820
00821
00822 typeFiberLossGain TypeFiberLossGain;
00823
00824 typeFiberAmplifierNoise TypeFiberAmplifierNoise;
00825
00828
00829 double FiberAmplifierSpontaneousEmissionFactor;
00830
00832
00848 double FiberAmplifierNoiseMaxStepSizeFactor;
00849
00851
00852
00853
00854
00855
00856
00857
00858
00859
00860
00861
00862
00863
00864
00865
00866
00867
00868
00869
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;
00982
00983 double ReferenceFreq;
00984 double ReferenceWavelength;
00985
00986
00987 double DispersionFiberCenterWavelength;
00988 double DispSlopeFiberCenterWavelength;
00989
00992
00993 bool SetFstSndOrDispDirectlyFlag;
00994
00995 double FstOrDispFiber;
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
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
01046
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
01084
01085 double *OutputPDVector;
01086 double *InputPDVector;
01087
01088
01089
01090 double PMD;
01091 double MeanDGDPerSqrtLength;
01092
01093
01094
01095 double ScatteringStepSize;
01096 cplx EulerMatrix[2][2];
01097
01098 int NumberScatterings;
01099 double TotalLengthFiber;
01100 double LengthFiberExceptLast, LengthFiberLast;
01101
01102
01103
01104 double * Theta;
01105 double * Phi;
01106 double * Psi;
01107
01108 double *PDVectorHai;
01109
01110
01111 cplx *JonesMatrix;
01112 int NumberOfChannels;
01113 double *FreqChannels;
01114
01115
01116
01117
01118 };
01119
01120 #endif
01121
01122
01123
01124
01125