Open PaperOpt
OpenPaperOpt/WavePacket.h
Go to the documentation of this file.
00001 
00002 
00003 // WavePacket.h: interface for the WavePacket class.
00004 
00005 #if !defined(AFX_WAVEPACKET_H__CE436FB5_8CBD_11D5_803C_00609705562A__INCLUDED_)
00006 #define AFX_WAVEPACKET_H__CE436FB5_8CBD_11D5_803C_00609705562A__INCLUDED_
00007 
00008 #if _MSC_VER >= 1000
00009 #pragma once
00010 #pragma warning(disable:4005)
00011 
00012 #endif // _MSC_VER >= 1000
00013 #include <math.h>
00014 #include <list>
00015 #include <iostream>
00016 #include <fstream>
00017 #include <string>
00018 
00019 #include "V3.h"
00020 #include "V2.h"
00021 using namespace std;
00022 
00023 //----------------------------------------------------------------------------------------
00024 
00025 #define INCOMING -9999
00026 #define ABSORBED 9999
00027 #define REF_SURF 10
00028 #define REF  11
00029 #define TRA 12 
00030 #define ERROR -10   
00031 
00032 //#define REF_SURF 11
00033 
00034 class WavePacket  
00035 {
00036 public:
00037         
00038         WavePacket() {mLen=0;mNumRefr=0;mNumScat=0;obj_num=INCOMING;mRefrInd=1;}
00039         //TODO check the refr index of wp if coming from other medium
00040         
00041         WavePacket& operator=(const WavePacket& wp){
00042                 //mState = wp.mState;
00043                 mLen =  wp.mLen;
00044                 mNumRefr = wp.mNumRefr;
00045                 mNumScat = wp.mNumScat;
00046                 obj_num = wp.obj_num;
00047                 mPos = wp.mPos;
00048                 mDir = wp.mDir;
00049                 mPol = wp.mPol;
00050                 mRefrInd = wp.mRefrInd;
00051                 return *this;
00052         }
00053         
00054         void WpError(std::string message){
00055 
00056                 this->obj_num =ERROR;
00057                 this->mErrorType = message;
00058         }
00059         
00060         // newPos is assumed to be in the positive travelling direction
00061         // -- no checks are made.
00062         void mTravelToPosition(V3 <double>& newPos) {
00063                 
00064                 V3 <double> temp = newPos-mPos;
00065                 mLen += temp.LengthVector() * mRefrInd;
00066                 mLastZpos = mPos.Z();
00067                 mPos = newPos;
00068         }
00069 
00070         //TODO should this be a distribution?
00071         void mIsotropicScattering();
00072 
00073         void mLambertianReflectance();
00074 
00075         // Sposition is assumed to be in the positive travelling
00076         // direction -- no checks are made.
00077         void mTravelToSposition() {
00078                 
00079                 V3 <double> temp = (mSposition-mPos);
00080                 mLen += temp.LengthVector() * mRefrInd;
00081                 mPos = V3 <double> (mSposition);
00082         }
00083         
00084         // One can use t to increment mLen. However, don't
00085         // forget to update the other travelling functions as well!
00086         int mTravel(double t){
00087                 if(t<0){
00088                         WpError("t negative in mTravel");
00089                         return(0);
00090                 }
00091                 mLastZpos = mPos.Z();
00092                 mPos.X(mPos.X()+t*mDir.X());
00093                 mPos.Y(mPos.Y()+t*mDir.Y());
00094                 mPos.Z(mPos.Z()+t*mDir.Z());
00095                 mLen += t * mRefrInd;
00096                 return(1);
00097         }
00098         void mCalcPolSp();
00115         V3 <double> mPos;
00116         V3 <double> mDir;
00117         V3 <double> mPol;
00118         V3 <double> mSnormal;
00119         V3 <double> mSposition;
00120         string mErrorType;
00121         
00122         double mLen;            //traveled path 
00123         double mEnergy;         //relative energy of the wave packet
00124         double mLastZpos;       //last z-positio before leaving structure
00125         int   mNumRefr;         //Number of refractions and reflections
00126         int mNumScat;       //Number of scattering events in the bulks
00127         int   obj_num;      //object where the wp is
00128         float mLambda;
00129 
00130         int nbr_wp;                             //the processing number of the wp in the main loop
00131         int nbr_lambda;
00132         double mRefrInd;                //index of the medium where the wp is 
00133 
00134         //TODO: make sure mRefrInd is updated in all objects and components. Check also that mLen is always updated
00135         double mPpol,mSpol;     // polarisation
00136 
00137         bool hasfluored; //set to 1 when wp has been fluoresced
00138         int nbrFluo; // LC temp tbr 06/01/10
00139         int nbrAbs;
00140 };      
00141 #endif // !defined(AFX_WAVEPACKET_H__CE436FB5_8CBD_11D5_803C_00609705562A__INCLUDED_)
00142 
00143 
00144 
00145