Changeset 1055 for trunk/source/processes/optical
- Timestamp:
- May 28, 2009, 4:26:57 PM (15 years ago)
- Location:
- trunk/source/processes/optical
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/source/processes/optical/History
r1007 r1055 16 16 * Reverse chronological order (last date on top), please * 17 17 ---------------------------------------------------------- 18 19 23th Mar 2009 Peter Gumplinger (op-V09-02-01) 20 for complex index of refraction: (1)resample the reflectivity 21 every time in the do-while of DielectricMetal, but don't 22 re-calculate theFacetNormal (which has already been chosen 23 in CalculateReflectivity), also (2) avoid an infinite loop by 24 resetting iTE and iTM inside the do-while of GetReflectivity; 25 both are bug-fixes. 26 27 14th Jan 2009 Peter Gumplinger (op-V09-02-00) 28 respond to bug report 1040 by fixing G4OpBoundaryProcess.cc 18 29 19 30 07th Nov 2008 Peter Gumplinger (op-V09-01-09) -
trunk/source/processes/optical/include/G4OpBoundaryProcess.hh
r1007 r1055 25 25 // 26 26 // 27 // $Id: G4OpBoundaryProcess.hh,v 1.1 8 2008/11/07 17:59:37gum Exp $28 // GEANT4 tag $Name: geant4-09-0 2$27 // $Id: G4OpBoundaryProcess.hh,v 1.19 2009/03/23 21:18:20 gum Exp $ 28 // GEANT4 tag $Name: geant4-09-03-beta-cand-01 $ 29 29 // 30 30 // … … 54 54 // mail: gum@triumf.ca 55 55 // 56 // CVS version tag:57 56 //////////////////////////////////////////////////////////////////////// 58 57 … … 160 159 // Returns the Reflectivity on a metalic surface 161 160 162 void SetModel(G4OpticalSurfaceModel model); 161 void CalculateReflectivity(void); 162 163 void SetModel(G4OpticalSurfaceModel model); 163 164 // Set the optical surface model to be followed 164 165 // (glisur || unified). … … 195 196 196 197 G4OpticalSurface* OpticalSurface; 198 199 G4MaterialPropertyVector* PropertyPointer; 200 G4MaterialPropertyVector* PropertyPointer1; 201 G4MaterialPropertyVector* PropertyPointer2; 197 202 198 203 G4double Rindex1; … … 308 313 309 314 theStatus = LobeReflection; 310 theFacetNormal = GetFacetNormal(OldMomentum,theGlobalNormal); 315 if ( PropertyPointer1 && PropertyPointer2 ){ 316 } else { 317 theFacetNormal = 318 GetFacetNormal(OldMomentum,theGlobalNormal); 319 } 311 320 G4double PdotN = OldMomentum * theFacetNormal; 312 321 NewMomentum = OldMomentum - (2.*PdotN)*theFacetNormal; -
trunk/source/processes/optical/src/G4OpBoundaryProcess.cc
r1007 r1055 178 178 else { 179 179 G4cerr << " G4OpBoundaryProcess/PostStepDoIt(): " 180 << " The Navigator reports that it returned an invalid normal" 181 << G4endl; 180 << " The Navigator reports that it returned an invalid normal" 181 << G4endl; 182 G4Exception("G4OpBoundaryProcess::PostStepDoIt", 183 "Invalid Surface Normal", 184 EventMustBeAborted, 185 "Geometry must return valid surface normal"); 182 186 } 183 187 … … 282 286 } 283 287 284 G4MaterialPropertyVector* PropertyPointer;285 G4MaterialPropertyVector* PropertyPointer1;286 G4MaterialPropertyVector* PropertyPointer2;287 288 288 PropertyPointer = 289 289 aMaterialPropertiesTable->GetProperty("REFLECTIVITY"); … … 303 303 } else if (PropertyPointer1 && PropertyPointer2) { 304 304 305 G4double RealRindex = 306 PropertyPointer1->GetProperty(thePhotonMomentum); 307 G4double ImaginaryRindex = 308 PropertyPointer2->GetProperty(thePhotonMomentum); 309 310 // calculate FacetNormal 311 if ( theFinish == ground ) { 312 theFacetNormal = 313 GetFacetNormal(OldMomentum, theGlobalNormal); 314 } else { 315 theFacetNormal = theGlobalNormal; 316 } 317 318 G4double PdotN = OldMomentum * theFacetNormal; 319 cost1 = -PdotN; 320 321 if (std::abs(cost1) < 1.0 - kCarTolerance) { 322 sint1 = std::sqrt(1. - cost1*cost1); 323 } else { 324 sint1 = 0.0; 325 } 326 327 G4ThreeVector A_trans, A_paral, E1pp, E1pl; 328 G4double E1_perp, E1_parl; 329 330 if (sint1 > 0.0 ) { 331 A_trans = OldMomentum.cross(theFacetNormal); 332 A_trans = A_trans.unit(); 333 E1_perp = OldPolarization * A_trans; 334 E1pp = E1_perp * A_trans; 335 E1pl = OldPolarization - E1pp; 336 E1_parl = E1pl.mag(); 337 } 338 else { 339 A_trans = OldPolarization; 340 // Here we Follow Jackson's conventions and we set the 341 // parallel component = 1 in case of a ray perpendicular 342 // to the surface 343 E1_perp = 0.0; 344 E1_parl = 1.0; 345 } 346 347 //calculate incident angle 348 G4double incidentangle = GetIncidentAngle(); 349 350 //calculate the reflectivity depending on incident angle, 351 //polarization and complex refractive 352 353 theReflectivity = 354 GetReflectivity(E1_perp, E1_parl, incidentangle, 355 RealRindex, ImaginaryRindex); 305 CalculateReflectivity(); 356 306 357 307 } else { … … 591 541 if( !G4BooleanRand(theReflectivity) && n == 1 ) { 592 542 593 // Comment out DoAbsorption if you wish to have594 // 543 // Comment out DoAbsorption and uncomment theStatus = Absorption; 544 // if you wish to have Transmission instead of Absorption 595 545 596 546 DoAbsorption(); 597 theStatus = Absorption;547 // theStatus = Absorption; 598 548 break; 599 549 600 550 } 601 551 else { 552 553 if (PropertyPointer1 && PropertyPointer2) { 554 if ( n > 1 ) { 555 CalculateReflectivity(); 556 if ( !G4BooleanRand(theReflectivity) ) { 557 DoAbsorption(); 558 break; 559 } 560 } 561 } 602 562 603 563 if ( theModel == glisur || theFinish == polished ) { … … 618 578 else { 619 579 620 if(theStatus==LobeReflection)theFacetNormal = 621 GetFacetNormal(OldMomentum,theGlobalNormal); 580 if(theStatus==LobeReflection){ 581 if ( PropertyPointer1 && PropertyPointer2 ){ 582 } else { 583 theFacetNormal = 584 GetFacetNormal(OldMomentum,theGlobalNormal); 585 } 586 } 622 587 623 588 G4double PdotN = OldMomentum * theFacetNormal; … … 962 927 963 928 do { 964 if(G4UniformRand()*real(Reflectivity) > real(Reflectivity_TE))iTE = -1; 965 if(G4UniformRand()*real(Reflectivity) > real(Reflectivity_TM))iTM = -1; 929 if(G4UniformRand()*real(Reflectivity) > real(Reflectivity_TE)) 930 {iTE = -1;}else{iTE = 1;} 931 if(G4UniformRand()*real(Reflectivity) > real(Reflectivity_TM)) 932 {iTM = -1;}else{iTM = 1;} 966 933 } while(iTE<0&&iTM<0); 967 934 … … 969 936 970 937 } 938 939 void G4OpBoundaryProcess::CalculateReflectivity() 940 { 941 G4double RealRindex = 942 PropertyPointer1->GetProperty(thePhotonMomentum); 943 G4double ImaginaryRindex = 944 PropertyPointer2->GetProperty(thePhotonMomentum); 945 946 // calculate FacetNormal 947 if ( theFinish == ground ) { 948 theFacetNormal = 949 GetFacetNormal(OldMomentum, theGlobalNormal); 950 } else { 951 theFacetNormal = theGlobalNormal; 952 } 953 954 G4double PdotN = OldMomentum * theFacetNormal; 955 cost1 = -PdotN; 956 957 if (std::abs(cost1) < 1.0 - kCarTolerance) { 958 sint1 = std::sqrt(1. - cost1*cost1); 959 } else { 960 sint1 = 0.0; 961 } 962 963 G4ThreeVector A_trans, A_paral, E1pp, E1pl; 964 G4double E1_perp, E1_parl; 965 966 if (sint1 > 0.0 ) { 967 A_trans = OldMomentum.cross(theFacetNormal); 968 A_trans = A_trans.unit(); 969 E1_perp = OldPolarization * A_trans; 970 E1pp = E1_perp * A_trans; 971 E1pl = OldPolarization - E1pp; 972 E1_parl = E1pl.mag(); 973 } 974 else { 975 A_trans = OldPolarization; 976 // Here we Follow Jackson's conventions and we set the 977 // parallel component = 1 in case of a ray perpendicular 978 // to the surface 979 E1_perp = 0.0; 980 E1_parl = 1.0; 981 } 982 983 //calculate incident angle 984 G4double incidentangle = GetIncidentAngle(); 985 986 //calculate the reflectivity depending on incident angle, 987 //polarization and complex refractive 988 989 theReflectivity = 990 GetReflectivity(E1_perp, E1_parl, incidentangle, 991 RealRindex, ImaginaryRindex); 992 }
Note: See TracChangeset
for help on using the changeset viewer.