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 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
00743
00744
00745
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
00794
00795 void ApplySimpleRamanOperator(double CurrentZValueWithinFiber2,
00796 double ZStep2);
00797
00798 void ApplyFullRamanOperator(double CurrentZValueWithinFiber2,double ZStep2);
00799
00800
00801
00802
00803
00804 ofstream StepSizesFile;
00805
00806 int OutputStepSizesFlag;
00807 int StepSizesFileMode;
00808 string Job;
00809
00810 typeSimulation TypeSimulation;
00811
00813
00814
00815
00816
00817
00818
00819
00820
00821
00822
00823
00824
00825
00826
00827
00828
00829
00830
00831
00832
00833 typeSolver TypeSolver;
00834
00835 typeStepSizes TypeStepSizes;
00836
00837
00838
00839 typeFiberLossGain TypeFiberLossGain;
00840
00841 typeFiberAmplifierNoise TypeFiberAmplifierNoise;
00842
00845
00846 double FiberAmplifierSpontaneousEmissionFactor;
00847
00849
00865 double FiberAmplifierNoiseMaxStepSizeFactor;
00866
00868
00869
00870
00871
00872
00873
00874
00875
00876
00877
00878
00879
00880
00881
00882
00883
00884
00885
00886
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;
01002
01003 double ReferenceFreq;
01004 double ReferenceWavelength;
01005
01006
01007 double DispersionFiberCenterWavelength;
01008 double DispSlopeFiberCenterWavelength;
01009
01012
01013 bool SetFstSndOrDispDirectlyFlag;
01014
01015 double FstOrDispFiber;
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
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
01066
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
01104
01105 double *OutputPDVector;
01106 double *InputPDVector;
01107
01108
01109
01110 double PMD;
01111 double MeanDGDPerSqrtLength;
01112
01113
01114
01115 double ScatteringStepSize;
01116 cplx EulerMatrix[2][2];
01117
01118 int NumberScatterings;
01119 double TotalLengthFiber;
01120 double LengthFiberExceptLast, LengthFiberLast;
01121
01122
01123
01124 double * Theta;
01125 double * Phi;
01126 double * Psi;
01127
01128 double *PDVectorHai;
01129
01130
01131 cplx *JonesMatrix;
01132 int NumberOfChannels;
01133 double *FreqChannels;
01134
01135
01136
01137
01138 };
01139
01140 #endif
01141
01142
01143
01144
01145