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
00061 enum typeFiberLossGain {LOSSY_FIBER = 0,
00062 FIBER_AMPLIFIER = 1};
00063
00098 enum typeFiberAmplifierNoise {FIBER_AMP_NOISE_OFF = 0,
00099 FIBER_AMP_NOISE_GAUSSIAN_WHITE = 2};
00100
00101
00222 enum typeFiberAmplifierGain {FIBER_AMP_UNSATURATED_FLAT_GAIN = 0,
00223 FIBER_AMP_SATURABLE_SUPERGAUSSFILT_GAIN = 1};
00224
00225
00227
00238 enum typeFastSaturableAbsorption {QUADRATIC_ANALYTIC=0,QUADRATIC=1};
00239
00240
00242
00294 enum typeStepSizes { LOCAL_ERROR_3RD = 1,
00295 LOCAL_ERROR_2ND = 2,
00296 WALK_OFF = 3,
00297 CONSTANT = 4 };
00298
00301
00302 enum { APPLY_ONCE = 0, APPLY_TWICE = 1 };
00303
00574 class OptFiberLocalError
00575 {
00576
00577 public:
00578
00580
00581 OptFiberLocalError(string InFileName, OptSignal *oOptSignal, RanNumGen *RNG2,
00582 string Job2);
00583
00584 void SetRamanAmpPointer(RamanAmp * oRaman2);
00585
00587
00588 ~OptFiberLocalError(void);
00589
00591
00592 void Propagate(double * PropagatedLength,int * ZStepNum);
00593
00596
00597 void PropagateWithRaman(double * PropagatedLength,
00598 int * ZStepNum,
00599 double RamanStartingLength2);
00600
00601 string WriteTypeSolver(void);
00602 string WriteTypeStepSizes(void);
00603 string WriteTypeFiberLossGain(void);
00604 string WriteTypeFiberAmplifierNoise(void);
00605 string WriteTypeFiberAmplifierGain(void);
00606
00607 void OpenStepSizesFile(string StepSizesFileName,int Mode);
00608 void WriteStepSizes(double PropagatedLength);
00609 void WriteAveragePowerdBm(double PropagatedLength2);
00610
00611
00612
00613 double GetFirstOrderDispersion() {return FstOrDispFiber;};
00614 double GetSecondOrderDispersion() {return SndOrDispFiber;};
00615 double GetFiberLength() {return LengthFiber;};
00616 double GetNepperAttenuationFiber() {return NepperAttenuationFiber;};
00617 double GetNonLinIndexFiber() {return NonLinIndexFiber;};
00618 double GetGamma() {return gamma;};
00619 double GetDeltaZ() {return DeltaZ;};
00620 int GetNumStepsBetweenScatterings() {return NumStepsBetweenScatterings;};
00621
00622 void SetNumStepsBetweenScatterings(int value)
00623 {NumStepsBetweenScatterings = value;
00624 SetFiberLengthsForPMD(); };
00625
00627
00628 double GetDispersion(double Wavelength);
00629
00630
00631
00632 void SetTypeStepSizes(int TypeStepSizes2);
00633 void SetWalkOffParameter(double WalkOffParameter2);
00634 void SetConstantDeltaZ(double DeltaZValue);
00635
00636
00637
00638 void SetOutputStepSizesFlag(int OutputStepSizesFlag2);
00639 void SetRelativeErrorGoal(double RelativeErrorGoal2);
00640
00641
00646 void SetFstOrDispFiber(double FstOrDispFiber2);
00647
00652 void SetSndOrDispFiber(double SndOrDispFiber2);
00653 void RecoverSndOrDispFiber();
00654
00655 void SetDispersion(double DispersionFiberRefWavelength,
00656 double DispSlopeFiberRefWavelength);
00657
00662 void SetGammaFiber(double gamma2);
00663 void RecoverGammaFiber();
00664
00667
00668 void SetAttenuationdB(double AttenuationFiber2);
00669
00673
00674 void SetNepperAttenuation(double NepperAttenuation2);
00675
00676
00678
00679 void SetFiberAmplifierUnsaturatedNepperGain(
00680 double FiberAmplifierUnsaturatedNepperGain2);
00681
00687
00688 void ComputeDeltaZMax(void);
00689
00690 void SetWriteAveragePowerdBmFlag(int Value);
00691
00692 void SetWritePulseWidthFlag(int Value) {WritePulseWidthFlag = Value;};
00693
00694 void SetFiberLength(double Value);
00695 void SetScatteringStepSize(double Value);
00696
00697
00698
00699 void GetNewFiberRealization(void);
00700 void SetFiberRealization(int SectionNumber,
00701 double Theta2, double Phi2, double Psi2);
00702
00703 void ApplyPMDCompleteScatteringFreqDomainOperator(
00704 int ScatteringSectionIndex);
00705
00706 void ComputeEulerMatrixAndUpdateOutputPDVector(int ScatteringSectionIndex);
00707
00708 void GetEulerMatrix(double theta,double phi,double psi);
00709
00710 void SetFiberLengthsForPMD(void);
00711
00712 void SetMeanDGDPerSqrtLength(double MeanDGDPerSqrtLength2);
00713 void SetPMD(double PMD2);
00714 double GetFreqDerivativeOfBirefringence(void);
00715
00716 double GetDGD(void);
00717
00718 void PropagateOutputPDVector(double Freq,
00719 double theta, double phi, double psi);
00720
00721 double GetExpectedDGD()
00722 {return sqrt(8./(3.*pi)*LengthFiber)*PMD; };
00723 double GetExpectedSndOrderDGD()
00724 {return sq(GetExpectedDGD())/sqrt(3.); };
00725 double GetMeanDGD_SqrtLength(void)
00726 {return sqrt(1e3)/1e-12*MeanDGDPerSqrtLength;};
00727
00728
00729 void UpdateJonesMatrixAfterBiregringence(double StepSizeZ);
00730
00731
00732
00733
00734 public:
00735
00736 RamanAmp * oRaman;
00737
00738
00739
00740 private:
00741
00742
00743
00744 void PropagateWithPMD(double * PropagatedLength,
00745 int * ZStepNum);
00746
00747 void PropagateWithoutPMD(double * PropagatedLength,
00748 int * ZStepNum);
00749
00750 void PropagateLocalError(double * PropagatedLength, int * ZStepNum);
00751
00752
00753 void PropagateConstStepSizeOrWalkOff(double * PropagatedLength,
00754 int * ZStepNum);
00755
00756
00757 void ResetVolatileVariables(void);
00758
00759 void inline UpdateFreq(void);
00760 void inline UpdateTime(void);
00761
00762 void ComputeWalkOffStepSize(void);
00763
00764 void ComputeDispersionOperator(double StepSizeZ);
00765 void ApplyDispersionOperator(bool ApplyTwiceFlag);
00766 void ApplySaturableGainOperator(double StepSizeZ);
00767 void ApplyFreqDomainOperator(bool ApplyDispersionTwiceFlag,
00768 double GainSatStepSizeZ);
00769
00770 void ApplyRamanOperator(double CurrentZValueWithinFiber2,double ZStep2);
00771 void ApplyTimeDomainOperator(double StepSizeZ);
00772
00773 void ApplyKerrNonlinearityOperator(double StepSizeZ);
00774 void ApplyFastSaturableAbsorptionOperator(double StepSizeZ);
00775 void ApplyFastSaturableAbsorptionQuadraticAnalytic(double StepSizeZ);
00776 void ApplyFastSaturableAbsorptionHeunsMethod(double StepSizeZ);
00777 cplx FastSaturableAbsorptionFunction(cplx u);
00778
00779 double ComputeMaxPower(void);
00780
00781 void CopyFftMatricesFreqData(fftMatrices * OrigData,fftMatrices * CopyOfData);
00782
00783 double ComputeThirdOrderSolutionAndRelativeError(void);
00784 double ComputeThirdOrderSolutionAndRelativeErrorOLD(void);
00785
00786
00787
00788
00789
00790
00791 void UpdateAccumulatedFirstOrderDispersion(double StepSize);
00792 void UpdateAccumulatedSecondOrderDispersion(double StepSize);
00793
00797
00798 void FiberAmplifierComputeSaturableGain(void);
00799
00803
00804 double FiberAmplifierComputeSaturableGainForHeunsMethod(bool FirstStep);
00805
00808
00809 double FiberAmplifierGetEnergyForHeunsMethod(bool FirstStep);
00810
00815
00828 void FiberAmplifierComputeNoiseAmplitudeFactor(double StepSize);
00829
00832
00833 void FiberAmplifierAddMonteCarloNoise(double StepSize);
00834
00835 void AllocateMemoryForEulerAngles(void);
00836
00837
00838
00839 void ApplySimpleRamanOperator(double CurrentZValueWithinFiber2,
00840 double ZStep2);
00841
00842 void ApplyFullRamanOperator(double CurrentZValueWithinFiber2,double ZStep2);
00843
00844
00845
00846
00847
00848 ofstream StepSizesFile;
00849
00850 int OutputStepSizesFlag;
00851 int StepSizesFileMode;
00852 string Job;
00853
00854 typeSimulation TypeSimulation;
00855
00857
00858
00859
00860
00861
00862
00863
00864
00865
00866
00867
00868
00869
00870
00871
00872
00873
00874
00875
00876
00877 typeSolver TypeSolver;
00878
00879 typeStepSizes TypeStepSizes;
00880
00881
00882
00883 typeFiberLossGain TypeFiberLossGain;
00884
00885 typeFiberAmplifierNoise TypeFiberAmplifierNoise;
00886
00889
00890 double FiberAmplifierSpontaneousEmissionFactor;
00891
00893
00909 double FiberAmplifierNoiseMaxStepSizeFactor;
00910
00912
00913
00914
00915
00916
00917
00918
00919
00920
00921
00922
00923
00924
00925
00926
00927
00928
00929
00930
00931
00932
00933
00934 double FiberAmplifierGainSaturationMaxGainPerStep;
00935
00937
00938 double FiberAmplifierNoiseAmplitudeFactor;
00939
00941
00942 typeFiberAmplifierGain TypeFiberAmplifierGain;
00943
00947
00948 double FiberAmplifierSuperGaussFiltGainCoefficient;
00949
00953
00954 int FiberAmplifierSuperGaussFiltOrder;
00955
00958
00959 double FiberAmplifierUnsaturatedNepperGain;
00960
00963
00964 double FiberAmplifierSaturationEnergy;
00965
00967
00968 double FiberAmplifierSaturableGainPerLength;
00969
00970 typeFastSaturableAbsorption TypeFastSaturableAbsorption;
00971
00973
00985 double FastSaturableAbsorptionCoefficient;
00986
00989
00990 bool DoFastSaturableAbsorptionFlag;
00991
00996
00997 bool DoTimeOperatorExactlyFlag;
00998
01000
01008 bool DispersionOperatorValid;
01009
01027 int ScalarSolverEightNinthsFlag;
01028
01029 OptSignal * oOptSignal;
01030 RanNumGen * RNG;
01031 cfftw *fft;
01032 fftMatrices sfftM;
01033
01034 cplx * FreqDomainOperatorX;
01035 cplx * FreqDomainOperatorY;
01036
01037 cplx * SqFreqDomainOperatorX;
01038 cplx * SqFreqDomainOperatorY;
01039
01040
01041 fftMatrices sfftM_Start;
01042 fftMatrices sfftM_Coarse;
01043 cplx * LaserWorkX;
01044 cplx * LaserWorkY;
01045
01046
01047 double LengthFiber;
01048
01049 double RamanStartingLength;
01050 double PropagatedLengthStartFiber;
01051 int NumStepsBetweenScatterings;
01052
01053 double ReferenceFreq;
01054 double ReferenceWavelength;
01055
01056
01057 double DispersionFiberCenterWavelength;
01058 double DispSlopeFiberCenterWavelength;
01059
01062
01063 bool SetFstSndOrDispDirectlyFlag;
01064
01065 double FstOrDispFiber;
01066 double SndOrDispFiber;
01067 double SndOrDispFiber_Save;
01068 double NonLinIndexFiber;
01069
01072
01073 int WithNonLin;
01074
01075 double EffectAreaFiber;
01076
01078
01092 double AttenuationFiber;
01093
01097
01098 double NepperAttenuationFiber;
01099
01100 typeRamanAmplification TypeRamanAmplification;
01101
01102
01103
01104 double RamanOnOffGaindB;
01105 double NepperRamanGain;
01106 double NepperRamanPumpLoss;
01107
01108 double CenterFreq;
01109 int qtPoints;
01110 double DeltaFreq;
01111 double gamma;
01112 double gamma_Save;
01113
01114 double CurrentZValueWithinFiber;
01115
01116
01117
01119
01124 double DeltaZ;
01125 double DeltaZMaxInfile, DeltaZMax;
01126
01128
01129 double DeltaZInitial;
01130
01131 bool InitializedDeltaZInitialFlag;
01132
01133 double WalkOffStepSize;
01134 double WalkOffLastStepSize;
01135 int WalkOffNumSteps;
01136 double WalkOffParameter;
01137
01138 double MaxPower;
01139
01140 double FWHM_Pulse;
01141
01142 bool TimeDataValid;
01143 bool FreqDataValid;
01144
01145 double RelativeError;
01146 double RelativeErrorGoal;
01147
01148 int LocalErrorFreqLimit;
01149
01150 int WriteAveragePowerdBmFlag;
01151 int WritePulseWidthFlag;
01152
01153
01154
01155 double *OutputPDVector;
01156 double *InputPDVector;
01157
01158
01159
01160 double PMD;
01161 double MeanDGDPerSqrtLength;
01162
01163
01164
01165 double ScatteringStepSize;
01166 cplx EulerMatrix[2][2];
01167
01168 int NumberScatterings;
01169 double TotalLengthFiber;
01170 double LengthFiberExceptLast, LengthFiberLast;
01171
01172
01173
01174 double * Theta;
01175 double * Phi;
01176 double * Psi;
01177
01178 double *PDVectorHai;
01179
01180
01181 cplx *JonesMatrix;
01182 int NumberOfChannels;
01183 double *FreqChannels;
01184
01185
01186
01187
01188 };
01189
01190 #endif
01191
01192
01193
01194
01195