00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #ifndef _OCS_RAMAN_AMP_HH_
00015 #define _OCS_RAMAN_AMP_HH_
00016
00017
00018 #include "ocsOptSignal.hh"
00019
00020 enum typeRamanNoise { RAMAN_NOISE_OFF = 0,
00021 RAMAN_NOISE_ON_RANDOM_PHASE = 1,
00022 RAMAN_NOISE_ON_GAUSSIAN_WHITE = 2,
00023 RAMAN_NOISE_ON_NO_RNG = 3 };
00024
00025
00026 class RamanAmp
00027 {
00028 public:
00029
00030
00031
00032
00033
00034
00035
00036 RamanAmp();
00037 ~RamanAmp();
00038 void ReleaseMemory();
00039 RamanAmp(string Job, string InFileName, RanNumGen *RNG2, int TNumFiber);
00040
00041 RamanAmp(string Job, string InFileName, RanNumGen *RNG2, OptSignal *oOptSignal1,
00042 int TNumFiber);
00043
00044 void AllocateMemory();
00045
00046 void PrepareSignal();
00047 void PrepareSignalCW();
00048 void PrepareSignalNonFourier();
00049 void SetGainProfile(double FiberLength, string InFileName);
00050 void ReadPlainFileGainLoss(double FiberLength,string InFileName);
00051 void ReadRamanGainLossWavelengthGrid(double FiberLength,string InFileName);
00052 void PrepareNextStep();
00053
00054
00055 void RamanIteration();
00056 void AddNoise();
00057 void PropagateSignalandNoise(OptSignal *NFSignal, OptSignal *Noise);
00058 void PropagateNoise(OptSignal *Noise);
00059
00060 void ShootingGeneticAlgorithmsVictor();
00061 void GeneticAlgorithmsVictor(double * Vector);
00062
00063
00064
00065 void PrepareSignalStart();
00066 void PrepareSignalLastRound();
00067 void CallLastRound();
00068 void ForwardLastRound(int StepI);
00069 double OptimizeForwardIntegrationLastRound(int IntStepI, double * PreSig);
00070 void SingalRayleighBScattteringBackward(int StepI);
00071 void DoubleRayleighBScattteringForward(int StepI);
00072 void SetPumpPower(double Value);
00073
00074 void ShootingGAVictor();
00075 void ShootingGA();
00076 void ShootingGAVaryCW();
00077 void ShootingGeneticAlgorithms(double VectorEqSpace);
00078 void ShootingGeneticAlgorithmsVaryCW(double VectorEqSpace);
00079 void ShootingIntegration(int NExtItr);
00080 void ShootingIntegrationExample(int NExtItr);
00081 void GetPumpInitGuessFromIntg(double * TargetAlpha);
00082 void UpdateIndividualWavelength(double VectorSpaceUpdate);
00083 void UpdateIndividualWavelength(int Num, double * VectorUpdate,
00084 double Space, double CW);
00085 void GeneticAlgorithmsVaryCW(double * Vector, double PumpSpace, double * CW);
00086 void GeneticAlgorithms(double * Vector);
00087 void CalculateFrel();
00088
00089 void InitRamanIteration();
00090 void RelaxRamanIteration();
00091 void ForwardStep(int StepI);
00092 void BackwardStep(int StepI);
00093 double OptimizeForwardIntegration(int IntStepI, double * PreSig);
00094 double OptimizeBackwardIntegration(int IntStepI, double * PrePum);
00095
00096 void FirstGuessForwardShooting(int IntStepI, double * PreSig, double * PrePum);
00097 void ShootingRamanIteration();
00098 void PrePumpShooting(int PreShootingStepI);
00099
00100 void SignalOnlyPropagation(int PreShootingStepI);
00101 void PreSignalShooting(int PreShootingStepI);
00102 void PreSignalShootingWOA(int PreShootingStepI);
00103
00104 void ForwardShooting(int StepI);
00105
00106
00107
00108 double OptimizeForwardShootingIntegration(int IntStepI, double * PreSig, double * PrePum);
00109 double OptimizeForwardPumpShootingIntegration(int IntStepI, double * PreSig, double * PrePum);
00110 double OptimizeForwardSignalShootingIntegration(int IntStepI, double * PreSig, double * PrePum);
00111 void InternalRelaxationInForwardShooting(int IntStepI, double * PreSig, double * PrePum);
00112
00113 void ParallelCorrection(double * ShootingValue, double * Target);
00114 void ParallelCorrectionNewton(double * ShootingValue, double * Target);
00115 void OneByOneCorrection(double * ShootingValue, double * Target);
00116 void ParallelIntgCorrection(double * ShootingValue, double * Target);
00117 void ParallelIntgCorrectionNewton(double *ShootingValue, double * Target);
00118 void UEvolution(int StepI, double * MatrixU);
00119
00120 void GetMatrixW(int WStepI, double * MatrixW);
00121 void GaussianElimination(double * MatrixU, double * CorrectP, double * EpxirP);
00122 void MatrixCopy(double * M1, double * M2, int M, int N);
00123 void MatrixMultiply(double * M1, double * M2, int N);
00124 void MatrixPlus(double * M1, double * M2, int N);
00125 void MatrixPlus(double * M1, double * M2, int M, int N);
00126 void DisplayM(double * M1 , int M , int N);
00127 void MatrixDivid(double * M1, double M, int N);
00128 void MatrixDivid(double * M1, double Num, int M, int N);
00129 void MatrixMultiply(double * M1, double M2, int N);
00130 void MatrixSubtract(double * M1, double * M2, int M, int N);
00131 void MatrixReducedMultiply(double * M1, double * M2, int N , int P);
00132
00133
00134
00135
00136 double GetTempDepFactor(double Wavelength1,double Wavelength2);
00137 double GetRamanGainFreqGrid(double Wavelength1, double Wavelength2, int NumSteps);
00138 double GetRamanGainFreqGrid(double Wavelength1, double Wavelength2);
00139 double GetRamanGain(double Wavelength1, double Wavelength2, int NumSteps);
00140 double GetRamanGain(double Wavelength1, double Wavelength2);
00141 double GetRamanGainClose(double Wave1, double Wave2, int Index);
00142 double GetAttenuationFiber(double Wavelength);
00143 double GetAttenuationFiber(double Wavelength, int NumSteps );
00144
00145 double GetRamanPowerFreqIndex(double Z, int SignalFreqIndex);
00146 void SetAmpLength(double Value);
00147 void SetTypeRamanNoise(typeRamanNoise TypeRamanNoise2);
00148 void DoubleRamanPumpPower();
00149
00150 string WriteTypeRamanNoise(void);
00151 void WriteSignalWaveLthPower(string OutFileName, int Num);
00152 void WriteSignalWaveLthPowerWith$(string OutFileName, int Num);
00153 void WritePumpWaveLthPower(string OutFileName, int Num);
00154 void WritePumpPower(string OutFileName);
00155 void WritePumpPowerdB(string OutFileName);
00156 void WriteSignalOutputPower(string OutFileName);
00157 void WriteSignalOutputPowerdB(string OutFileName);
00158 void WriteSignalConvergence(string OutFileName);
00159 void WriteSignalTrack(string OutFileName, int Num);
00160 void WriteSignalTrack(string OutFileName);
00161 void WriteAveragePowerdBm(int loop);
00162 void WriteEqIntgData(string InFileName);
00163 void WriteGainShapeData(string InFileName,string OutFileName1,string OutFileName2);
00164 void WriteCentralWavelength(string InFileName,string OutFileName1);
00165 void WriteSignalNoise(OptSignal *Signal1, OptSignal *NFSignal, OptSignal *N, string
00166 OutSignalNoiseFileName);
00167
00168
00169
00170
00171
00172 void RamanTransient();
00173
00174 private:
00175 void Calculatedsdt(double * oSigTemp,double * oPumTemp,double * dPsigdt,double * dPpumdt);
00176 void Mac24BF(double * oSignalTemp,double * oPumpTemp,double * dPsdt,double * dPpdt);
00177 void Mac24FB(double * oSignalTemp,double * oPumpTemp,double * dPsdt,double * dPpdt);
00178 void CalculateForwarddsdt(double * oSigTemp,double * oPumTemp,double * dPsigdt,double * dPpumdt);
00179 void CalculateBackwarddsdt(double * oSigTemp,double * oPumTemp,double * dPsigdt,double * dPpumdt);
00180
00181
00182
00183
00184
00185 void ReadPlainFileGain(double FiberLength,string InFileName);
00186 void ReadPlainFileLoss(double FiberLength, string InFileName);
00187 double WaveLengthStart;
00188 double WavelengthStep;
00189
00190
00191
00192 private:
00193 typeRamanNoise TypeRamanNoise;
00194
00195 double DeltaZ(int NumSteps);
00196
00197
00198 double * oSignalWaveLth;
00199 double * oSignalPower;
00200 double * oSignalPowerPre;
00201 double * oSignalSample;
00202 double * oSignalTrack;
00203 double * oIntgSigPower;
00204 double * SigFEnergy;
00205
00206 double * oASEWaveLth;
00207 double * oSRBWaveLth;
00208 double * oDRBWaveLth;
00209 double * oASEPower;
00210 double * oSRBPower;
00211 double * oDRBPower;
00212
00213 double * oPumpWaveLth;
00214 double * oPumpPower;
00215 double * oPumpTarget;
00216 double * oPumpTrack;
00217 double * oPumpTargetBackup;
00218 double * oPumpPowerPre;
00219 double * oPumpPower45Converted;
00220 double * oPumpWaveLthInput;
00221 double * oPumpPowerInput;
00222
00223 double * oPumpIntgTarget;
00224
00225
00226 double * oRamanGain;
00227 double * oLoss;
00228 double PumpAttenuation;
00229
00230 double * DeltaPsignal;
00231 double DeltaPsignalsign;
00232 double * DeltaPpump;
00233 double DeltaPpumpsign;
00234
00235 double * PreCorrectP;
00236
00237 double CompCoeff;
00238 double * DeltaPpumpTotal;
00239 double * DeltaPsignalTotal;
00240
00241 int TypeIntergration;
00242
00243 int TypeAlgorithm;
00244 int TypeCorrect;
00245 double WeightCorrect;
00246 double IterationAccurateTh;
00247 double ShootingAccurateTh;
00248
00249
00250
00251 double RamanStartLength;
00252 double AmpLength;
00253 double DeltaZConst;
00254 double * DeltaZArray;
00255 int NumSigCh;
00256 int NumPumCh;
00257 int NumASECh;
00258 int NumSRBCh;
00259 int NumDRBCh;
00260
00261 int NumFibersPumped;
00262 int NumFiberIndex;
00263 int * FiberLocation;
00264
00265
00266 int PumpWavelengthForGain;
00267 double WaveLengthStartGain;
00268 double WavelengthStepGain;
00269 int NumGainWidth;
00270 double WaveLengthStartLoss;
00271 double WavelengthStepLoss;
00272 int NumLossWidth;
00273 double FreqStartGain;
00274 double FreqStepGain;
00275
00276
00277 double GlobleRipple;
00278
00279 int NumPumChTotal;
00280 int NumCh;
00281 int NumIteration;
00282 int NumIntItr;
00283
00284 int TypeGeneticAlgorithms;
00285 int Population;
00286 int SelectionFixedNum;
00287 double CrossRate;
00288 double MutationRate;
00289 int StartNumSpace;
00290 int EndNumSpace;
00291
00292
00293 int AccurateSign;
00294
00295 int BlowupSign;
00296 int FixSignalShootingSign;
00297 int FixPumpShootingSign;
00298
00299 double RayleighBackscatterCoeff;
00300 int NumZSteps;
00301
00302 string JobRaman;
00303
00304 int NumTSteps ;
00305 double DeltaT ;
00306
00307
00308 OptSignal *oOptSignal;
00309 RanNumGen *RNG;
00310
00311 cfftw *fft;
00312 fftMatrices sfftM;
00313 int qtPoints;
00314 double DeltaFreq, FreqWindow, DeltaTime, TimeWindow;
00315 int ObjectInitialized;
00316 int TypeOptFilter;
00317 int OrderOptFilter;
00318 double FreqFWHM_OptFilter;
00319 double RelativeCenterFreqOptFilter;
00320
00321 double PumpPowerFactor;
00322 string InFileNameSave;
00323 int NoFourierSignal;
00324 int ReadPlainFileGainLossFlag;
00325 int ReadRamanGainLossWavelengthGridFlag;
00326
00327 };
00328
00329 #endif
00330
00331
00332
00333
00334