Multiple Optical Surface

Hi,

I’m trying to understand if I wrote correctly this part of work about optical surface. I have a Cylinder (white) of Teflon, a Integrating sphere (blue) of water and a spherical cap (green) of Olive Oil.

So, the surface that i need are Teflon-Water and Water-Oil and Oil Teflon, right? If this is right, i wrote that code:

//first surface
  G4OpticalSurface* OpTeflonWaterSurface = new G4OpticalSurface("TeflonWaterSurface");
  

	 OpTeflonWaterSurface->SetType(dielectric_dielectric);
	 OpTeflonWaterSurface->SetModel(unified);
	 OpTeflonWaterSurface->SetFinish(groundfrontpainted);

 //Superficie di contatto tra Cilindro (teflon) e sfera integratrice (acqua)
 /*G4LogicalBorderSurface* TeflonWaterSurface =*/ new
    G4LogicalBorderSurface("LSB_TeflonWaterSurface", physSferaIntegratrice, physCilindro, OpTeflonWaterSurface);

  
  G4MaterialPropertiesTable* TEFLON_MPT = new G4MaterialPropertiesTable();


  std::vector<G4double> energy = {3.98*eV, 4.00*eV, 4.02*eV, 4.04*eV, 4.06*eV, 4.08*eV, 4.10*eV, 4.12*eV, 4.14*eV, 4.16*eV, 4.18*eV, 4.20*eV, 4.22*eV, 4.24*eV, 4.26*eV, 4.28*eV, 4.30*eV, 4.32*eV, 4.34*eV, 4.36*eV, 4.38*eV, 4.40*eV, 4.42*eV, 4.44*eV, 4.46*eV, 4.48*eV, 4.50*eV, 4.52*eV, 4.54*eV, 4.56*eV, 4.58*eV, 4.60*eV, 4.62*eV, 4.64*eV, 4.66*eV, 4.68*eV, 4.70*eV, 4.72*eV, 4.74*eV, 4.76*eV, 4.78*eV, 4.80*eV, 4.82*eV, 4.84*eV, 4.86*eV, 4.88*eV, 4.90*eV, 4.92*eV, 4.94*eV, 4.96*eV};
  std::vector<G4double> reflectivity = {0.984, 0.984, 0.984, 0.983, 0.983, 0.983, 0.983, 0.982, 0.982, 0.981, 0.980, 0.980, 0.979, 0.979, 0.978, 0.978, 0.977, 0.977, 0.976, 0.976, 0.975, 0.974, 0.974, 0.973, 0.973, 0.972, 0.972, 0.971, 0.971, 0.97, 0.970, 0.969, 0.968, 0.968, 0.967, 0.967, 0.966, 0.966, 0.964, 0.964, 0.963, 0.963, 0.962, 0.961, 0.961, 0.960, 0.960, 0.959, 0.959, 0.959};
  std::vector<G4double> trasmittance = {0.016, 0.016, 0.016, 0.017, 0.017, 0.017, 0.017, 0.018, 0.018, 0.019, 0.02, 0.02, 0.021, 0.021, 0.022, 0.022, 0.023, 0.023, 0.024, 0.024, 0.025, 0.026, 0.026, 0.027, 0.027, 0.028, 0.028, 0.029, 0.029, 0.03, 0.03, 0.031, 0.032, 0.032, 0.033, 0.033, 0.034, 0.034, 0.036, 0.036, 0.037, 0.037, 0.038, 0.039, 0.039, 0.04, 0.04, 0.041, 0.041, 0.041};
  std::vector<G4double> rindex_teflon = {1.3, 1.3, 1.3, 1.3, 1.3, 1.3, 1.3, 1.3, 1.3, 1.3, 1.3, 1.3, 1.3, 1.3, 1.3, 1.3, 1.3, 1.3, 1.3, 1.3, 1.3, 1.3, 1.3, 1.3, 1.3, 1.3, 1.3, 1.3, 1.3, 1.3, 1.3, 1.3, 1.3, 1.3, 1.3, 1.3, 1.3, 1.3, 1.3, 1.3, 1.3, 1.3, 1.3, 1.3, 1.3, 1.3, 1.3, 1.3, 1.3, 1.3};
  std::vector<G4double> absorption = {1.0*um, 1.0*um, 1.0*um, 1.0*um, 1.0*um, 1.0*um, 1.0*um, 1.0*um, 1.0*um, 1.0*um, 1.0*um, 1.0*um, 1.0*um, 1.0*um, 1.0*um, 1.0*um, 1.0*um, 1.0*um, 1.0*um, 1.0*um, 1.0*um, 1.0*um, 1.0*um, 1.0*um, 1.0*um, 1.0*um, 1.0*um, 1.0*um, 1.0*um, 1.0*um, 1.0*um, 1.0*um, 1.0*um, 1.0*um, 1.0*um, 1.0*um, 1.0*um, 1.0*um, 1.0*um, 1.0*um, 1.0*um, 1.0*um, 1.0*um, 1.0*um, 1.0*um, 1.0*um, 1.0*um, 1.0*um, 1.0*um, 1.0*um};       


  TEFLON_MPT->AddProperty("RINDEX", energy, rindex_teflon);
  TEFLON_MPT->AddProperty("ABSLENGTH", energy, absorption);
  TEFLON_MPT->AddProperty("REFLECTIVITY", energy, reflectivity);
  TEFLON_MPT->AddProperty("TRANSMITTANCE", energy, trasmittance);


  teflon_mat->SetMaterialPropertiesTable(TEFLON_MPT);
  
  OpTeflonWaterSurface->SetMaterialPropertiesTable(TEFLON_MPT);
  
  
  G4MaterialPropertiesTable* Water_MPT = new G4MaterialPropertiesTable();


  std::vector<G4double> rindex_water = {1.34, 1.34, 1.34, 1.34, 1.34, 1.34, 1.34, 1.34, 1.34, 1.34, 1.34, 1.34, 1.34, 1.34, 1.34, 1.34, 1.34, 1.34, 1.34, 1.34, 1.34, 1.34, 1.34, 1.34, 1.34, 1.34, 1.34, 1.34, 1.34, 1.34, 1.34, 1.34, 1.34, 1.34, 1.34, 1.34, 1.34, 1.34, 1.34, 1.34, 1.34, 1.34, 1.34, 1.34, 1.34, 1.34, 1.34, 1.34, 1.34, 1.34};
  std::vector<G4double> absorption_water = {344.8*cm, 344.8*cm, 344.8*cm, 344.8*cm, 344.8*cm, 344.8*cm, 344.8*cm, 344.8*cm, 344.8*cm, 344.8*cm, 344.8*cm, 344.8*cm, 344.8*cm, 344.8*cm, 344.8*cm, 344.8*cm, 344.8*cm, 344.8*cm, 344.8*cm, 344.8*cm, 344.8*cm, 344.8*cm, 344.8*cm, 344.8*cm, 344.8*cm, 344.8*cm, 344.8*cm, 344.8*cm, 344.8*cm, 344.8*cm, 344.8*cm, 344.8*cm, 344.8*cm, 344.8*cm, 344.8*cm, 344.8*cm, 344.8*cm, 344.8*cm, 344.8*cm, 344.8*cm, 344.8*cm, 344.8*cm, 344.8*cm, 344.8*cm, 344.8*cm, 344.8*cm, 344.8*cm, 344.8*cm, 344.8*cm, 344.8*cm};
  //std::vector<G4double> reflectivity_water = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; 
  //std::vector<G4double> trasmittance_water = {100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100}; 
  
  
  Water_MPT->AddProperty("RINDEX", energy, rindex_water);
  Water_MPT->AddProperty("ABSLENGTH", energy, absorption_water);
  //Water_MPT->AddProperty("REFLECTIVITY", energy, reflectivity_water);
  //Water_MPT->AddProperty("TRANSMITTANCE", energy, trasmittance_water);
  
  
  water_mat->SetMaterialPropertiesTable(Water_MPT);

  OpTeflonWaterSurface->SetMaterialPropertiesTable(Water_MPT);


   //second surface
  G4OpticalSurface* PolWaterSurface = new G4OpticalSurface("PolWaterSurface");

  //Superficie di contatto tra calotta inquinante (olio) e sfera integratrice (acqua)
 /*G4LogicalBorderSurface* PolWaterSurface =*/ new
    G4LogicalBorderSurface("LSB_PolWaterSurface", physSferaIntegratrice, physCalotta_Olio_oliva, PolWaterSurface);
  

  PolWaterSurface->SetType(dielectric_dielectric);
  PolWaterSurface->SetModel(unified);
  PolWaterSurface->SetFinish(polished); //controllare se dalambertiano o speculare


  std::vector<G4double> rindex_olio_oliva = {1.47, 1.47, 1.47, 1.47, 1.47, 1.47, 1.47, 1.47, 1.47, 1.47, 1.47, 1.47, 1.47, 1.47, 1.47, 1.47, 1.47, 1.47, 1.47, 1.47, 1.47, 1.47, 1.47, 1.47, 1.47, 1.47, 1.47, 1.47, 1.47, 1.47, 1.47, 1.47, 1.47, 1.47, 1.47, 1.47, 1.47, 1.47, 1.47, 1.47, 1.47, 1.47, 1.47, 1.47, 1.47, 1.47, 1.47, 1.47, 1.47, 1.47};
  std::vector<G4double> absorption_olio_oliva = {344.8*cm, 344.8*cm, 344.8*cm, 344.8*cm, 344.8*cm, 344.8*cm, 344.8*cm, 344.8*cm, 344.8*cm, 344.8*cm, 344.8*cm, 344.8*cm, 344.8*cm, 344.8*cm, 344.8*cm, 344.8*cm, 344.8*cm, 344.8*cm, 344.8*cm, 344.8*cm, 344.8*cm, 344.8*cm, 344.8*cm, 344.8*cm, 344.8*cm, 344.8*cm, 344.8*cm, 344.8*cm, 344.8*cm, 344.8*cm, 344.8*cm, 344.8*cm, 344.8*cm, 344.8*cm, 344.8*cm, 344.8*cm, 344.8*cm, 344.8*cm, 344.8*cm, 344.8*cm, 344.8*cm, 344.8*cm, 344.8*cm, 344.8*cm, 344.8*cm, 344.8*cm, 344.8*cm, 344.8*cm, 344.8*cm, 344.8*cm};
  //std::vector<G4double> reflectivity_olio_oliva = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; 
  //std::vector<G4double> trasmittance_olio_oliva = {100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100}; 

  
  G4MaterialPropertiesTable* Olio_MPT = new G4MaterialPropertiesTable();

  Olio_MPT->AddProperty("RINDEX", energy, rindex_olio_oliva);
  Olio_MPT->AddProperty("ABSLENGTH", energy, absorption_olio_oliva);
  //Olio_MPT->AddProperty("REFLECTIVITY", energy, reflectivity_olio_oliva);
  //Olio_MPT->AddProperty("TRANSMITTANCE", energy, trasmittance_olio_oliva);

  Olio_Oliva->SetMaterialPropertiesTable(Olio_MPT);

  PolWaterSurface->SetMaterialPropertiesTable(Olio_MPT);
  PolWaterSurface->SetMaterialPropertiesTable(Water_MPT);

  
  //third surface
  G4OpticalSurface* OpTeflonOilSurface = new G4OpticalSurface("TeflonOilSurface");
  

   OpTeflonWaterSurface->SetType(dielectric_dielectric);
   OpTeflonWaterSurface->SetModel(unified);
   OpTeflonWaterSurface->SetFinish(groundfrontpainted);

 //Superficie di contatto tra Cilindro (teflon) e sfera integratrice (acqua)
 /*G4LogicalBorderSurface* TeflonWaterSurface =*/ new
    G4LogicalBorderSurface("LSB_TeflonOilSurface", physCalotta_Olio_oliva, physCilindro, OpTeflonOilSurface);


  OpTeflonOilSurface->SetMaterialPropertiesTable(Olio_MPT);
  OpTeflonOilSurface->SetMaterialPropertiesTable(TEFLON_MPT);

It is right? Of course, from oil to water, or viceversa, the model is polished in order to take into account only the snell equation.

It’s difficult to read the code and say whether it is correct. I would suggest going through each surface and seeing if the behaviour is correct. Extended example optical/OpNovice2 was written with this in mind. Try boundary.mac macro.

A couple of comments.

  1. Maybe it’s not wrong, but it is confusing, to give the same material property table to a surface and a material.
  2. Logical border surfaces are ordered, so if you are interested in photons travelling from material A to material B, and B to A, you’ll need to logical border surfaces (or one logical skin surface).
2 Likes

Thanks @dsawkey, I will see this example and macro.

  1. Ohhh this is so useful for me. I don’t know how to give a property, correctly, to a surface, how can I do it? I searched in Internet and guide, but I didn’t find anything. This can help me so much.

  2. What do you mean? I already described every logical border surface, as you can see in the previous code ( I know, it is not so clear…)

  TEFLON_MPT->AddProperty("RINDEX", energy, rindex_teflon);
  TEFLON_MPT->AddProperty("ABSLENGTH", energy, absorption);
  TEFLON_MPT->AddProperty("REFLECTIVITY", energy, reflectivity);
  TEFLON_MPT->AddProperty("TRANSMITTANCE", energy, trasmittance);


  teflon_mat->SetMaterialPropertiesTable(TEFLON_MPT);
  
  OpTeflonWaterSurface->SetMaterialPropertiesTable(TEFLON_MPT);
  

For point 1, here you are assigning the same MPT (TEFLON_MPT) to a surface, and a material. These two entities have different material properties (e.g. the material has no REFLECTIVITY property). For the property names that are common, like RINDEX, you might want different values. Look at example OpNovice in OpNoviceDetectorConstruction to see a full example. It is also explained in the Book for Application Developers.

This must be a mistake.

1 Like

Sorry, I’m very confused (and yes, i checked the example).

  1. Can you write and example where you link properties to surface and material in the right way?

  2. Here we have two medium, oil and water, separated by a surface. I want do give the right property at that surface in order to obtain the snell law. Is correct? If not, how can i do in the right way?

Sorry for the dump questions, but I’m very confused, I never used the optical surface…

Thanks for your time and patient.

Logical border surfaces are ordered, so if you are interested in photons travelling from material A to material B, and B to A, you’ll need to logical border surfaces (or one logical skin surface).

I realize this is off-topic, but this is an active thread and I hope I can interject for just one comment. I actually just had an issue relating to this ordering behavior while setting up a new simulation. I am finishing multiple sides of a scintillator crystal with different finishes (Rough_LUT, Polished_LUT, …) so I need multiple “dummy” PVPlacements to delimit the borders between the side and the rest of the world.

I ended up doing the following:

// NB: do both orders because it matters
(void) new G4LogicalBorderSurface(partialName + "-border-surf-out-in", pv, scintPlacement, surf);
(void) new G4LogicalBorderSurface(partialName + "-border-surf-in-out", scintPlacement, pv, surf);

Would there be a way to make this more clear in the application developer’s guide, or maybe pin an existing thread about this already? It’s a pretty subtle behavior that was tripping me up for a while.

Thanks!
William

1 Like

If all you desire is Snell’s law and a “perfect” interface, then the default behavior between two surfaces will suffice. That is, you do not need to supply an optical surface between them. Just give the oil and the water the RINDEX and ABSLENGTH properties.

Please see the relevant Application Developer’s Guide section:

  1. For the simple case of a perfectly smooth interface between two dielectric materials, all the user needs to provide are the refractive indices (RINDEX) of the two materials stored in their respective G4MaterialPropertiesTables.
1 Like

If i Understand well, i just need to delete this part of my code:

  //third surface
  G4OpticalSurface* OpTeflonOilSurface = new G4OpticalSurface("TeflonOilSurface");
  

   OpTeflonWaterSurface->SetType(dielectric_dielectric);
   OpTeflonWaterSurface->SetModel(unified);
   OpTeflonWaterSurface->SetFinish(groundfrontpainted);

 //Superficie di contatto tra Cilindro (teflon) e sfera integratrice (acqua)
 /*G4LogicalBorderSurface* TeflonWaterSurface =*/ new
    G4LogicalBorderSurface("LSB_TeflonOilSurface", physCalotta_Olio_oliva, physCilindro, OpTeflonOilSurface);


  OpTeflonOilSurface->SetMaterialPropertiesTable(Olio_MPT);
  OpTeflonOilSurface->SetMaterialPropertiesTable(TEFLON_MPT);

?

Then, i also ask to you, how can i set, correctly, the property to a surface and to a material? Seeing my code @dsawkey said that it is bad written, but i don’t understand how to give a property to a surface and how to give property to a material.

Can you help me with my portion of code please?

Optical surfaces are kind of weird. They are an ad-hoc way to define how surfaces should interact. I will try to differentiate surfaces and materials to the best of my understanding here.

The material properties table for a material (like Olio_MPT in your example) define how optical photons should propagate through the olive oil. However the interface between the olive oil and e.g. the Teflon is treated separately.

In your code, if I am understanding it correctly, you have:

  • A block of Teflon with a sphere cut out of it
  • Part of the sphere filled with water
  • Part of the sphere filled with oil.

The interface between oil and water you want to be “perfect” and obey Snell’s law.
To achieve this, do not specify a surface between the oil and water.

The interface between the water or oil and Teflon should be diffuse.
To achieve this, set a perfectly diffuse boundary between the Teflon and the oil/water.

Here is an example of how that could look in code. Notice that

  • The material properties and surface properties are separate.
  • Only one Teflon optical surface is defined and it is re-used in two different border surfaces.
  • There is no border surface between the oil and water.
// this is the only place you need to define the teflon optical surface.
//first surface
auto* teflonOpticalSurface = new G4OpticalSurface("TeflonSurface");
teflonOpticalSurface->SetType(dielectric_dielectric);
teflonOpticalSurface->SetModel(unified);
teflonOpticalSurface->SetFinish(groundfrontpainted);
// sigma_alpha = 0 means no absorption by microfacets
teflonSurface->SetSigmaAlpha(0.);

//Superficie di contatto tra Cilindro (teflon) e sfera integratrice (acqua)
/*G4LogicalBorderSurface* TeflonWaterSurface =*/
(void) new G4LogicalBorderSurface(
	"LSB_TeflonWaterSurface",
	physSferaIntegratrice,
	physCilindro,
	teflonOpticalSurface);


// define MPTs for Teflon and the interface _separately_
auto* TEFLON_MPT = new G4MaterialPropertiesTable();
auto* teflonInterfaceMpt = new G4MaterialPropertiesTable();

std::vector<G4double> energy = {3.98*eV, 4.00*eV, 4.02*eV, 4.04*eV, 4.06*eV, 4.08*eV, 4.10*eV, 4.12*eV, 4.14*eV, 4.16*eV, 4.18*eV, 4.20*eV, 4.22*eV, 4.24*eV, 4.26*eV, 4.28*eV, 4.30*eV, 4.32*eV, 4.34*eV, 4.36*eV, 4.38*eV, 4.40*eV, 4.42*eV, 4.44*eV, 4.46*eV, 4.48*eV, 4.50*eV, 4.52*eV, 4.54*eV, 4.56*eV, 4.58*eV, 4.60*eV, 4.62*eV, 4.64*eV, 4.66*eV, 4.68*eV, 4.70*eV, 4.72*eV, 4.74*eV, 4.76*eV, 4.78*eV, 4.80*eV, 4.82*eV, 4.84*eV, 4.86*eV, 4.88*eV, 4.90*eV, 4.92*eV, 4.94*eV, 4.96*eV};
std::vector<G4double> reflectivity = {0.984, 0.984, 0.984, 0.983, 0.983, 0.983, 0.983, 0.982, 0.982, 0.981, 0.980, 0.980, 0.979, 0.979, 0.978, 0.978, 0.977, 0.977, 0.976, 0.976, 0.975, 0.974, 0.974, 0.973, 0.973, 0.972, 0.972, 0.971, 0.971, 0.97, 0.970, 0.969, 0.968, 0.968, 0.967, 0.967, 0.966, 0.966, 0.964, 0.964, 0.963, 0.963, 0.962, 0.961, 0.961, 0.960, 0.960, 0.959, 0.959, 0.959};
std::vector<G4double> trasmittance = {0.016, 0.016, 0.016, 0.017, 0.017, 0.017, 0.017, 0.018, 0.018, 0.019, 0.02, 0.02, 0.021, 0.021, 0.022, 0.022, 0.023, 0.023, 0.024, 0.024, 0.025, 0.026, 0.026, 0.027, 0.027, 0.028, 0.028, 0.029, 0.029, 0.03, 0.03, 0.031, 0.032, 0.032, 0.033, 0.033, 0.034, 0.034, 0.036, 0.036, 0.037, 0.037, 0.038, 0.039, 0.039, 0.04, 0.04, 0.041, 0.041, 0.041};

std::vector<G4double> rindex_teflon(energy.size(), 1.3);
std::vector<G4double> absorption(energy.size(), 1*um);

// only set RINDEX and ABSLENGTH for the material.
TEFLON_MPT->AddProperty("RINDEX", energy, rindex_teflon);
TEFLON_MPT->AddProperty("ABSLENGTH", energy, absorption);

// these properties correspond to surfaces; set them separately.
// see https://geant4-userdoc.web.cern.ch/UsersGuides/ForApplicationDeveloper/html/TrackingAndPhysics/physicsProcess.html#id9
teflonInterfaceMpt->AddProperty("REFLECTIVITY", energy, reflectivity);
teflonInterfaceMpt->AddProperty("TRANSMITTANCE", energy, trasmittance);
teflonInterfaceMpt->AddProperty("RINDEX", energy, rindex_teflon);

teflon_mat->SetMaterialPropertiesTable(TEFLON_MPT);
// here we set the properties to the table defined *only for the interface*
teflonOpticalSurface->SetMaterialPropertiesTable(teflonInterfaceMpt);


G4MaterialPropertiesTable* Water_MPT = new G4MaterialPropertiesTable();
std::vector<G4double> rindex_water(energy.size(), 1.34);
std::vector<G4double> absorption_water(energy.size(), 344.8*cm);
Water_MPT->AddProperty("RINDEX", energy, rindex_water);
Water_MPT->AddProperty("ABSLENGTH", energy, absorption_water);
water_mat->SetMaterialPropertiesTable(Water_MPT);

// This should not be set again. You have already set it above.
// OpTeflonWaterSurface->SetMaterialPropertiesTable(Water_MPT);


// Do not set a surfacee between water and olive oil if you want Fresnel refraction.
//second surface
// G4OpticalSurface* PolWaterSurface = new G4OpticalSurface("PolWaterSurface");

//Superficie di contatto tra calotta inquinante (olio) e sfera integratrice (acqua)
// G4LogicalBorderSurface* PolWaterSurface = new
// G4LogicalBorderSurface("LSB_PolWaterSurface", physSferaIntegratrice, physCalotta_Olio_oliva, PolWaterSurface);


// PolWaterSurface->SetType(dielectric_dielectric);
// PolWaterSurface->SetModel(unified);
// PolWaterSurface->SetFinish(polished); //controllare se dalambertiano o speculare


std::vector<G4double> rindex_olio_oliva(energy.size(), 1.47);
std::vector<G4double> absorption_olio_oliva(energy.size(), 344.8*cm);


G4MaterialPropertiesTable* Olio_MPT = new G4MaterialPropertiesTable();
Olio_MPT->AddProperty("RINDEX", energy, rindex_olio_oliva);
Olio_MPT->AddProperty("ABSLENGTH", energy, absorption_olio_oliva);
//Olio_MPT->AddProperty("REFLECTIVITY", energy, reflectivity_olio_oliva);
//Olio_MPT->AddProperty("TRANSMITTANCE", energy, trasmittance_olio_oliva);
Olio_Oliva->SetMaterialPropertiesTable(Olio_MPT);
// do not set these because you don't need the surface
// PolWaterSurface->SetMaterialPropertiesTable(Olio_MPT);
// PolWaterSurface->SetMaterialPropertiesTable(Water_MPT);


// you do not need another optical surface because the propertiese are the same as before
//third surface
// G4OpticalSurface* OpTeflonOilSurface = new G4OpticalSurface("TeflonOilSurface");
//
//
// OpTeflonWaterSurface->SetType(dielectric_dielectric);
// OpTeflonWaterSurface->SetModel(unified);
// OpTeflonWaterSurface->SetFinish(groundfrontpainted);

//Superficie di contatto tra Cilindro (teflon) e sfera integratrice (acqua)
/*G4LogicalBorderSurface* TeflonWaterSurface =*/
// here create a border between the teflon and olive oil using the already-defined surface
(void) new G4LogicalBorderSurface(
	"LSB_TeflonOilSurface",
	physCalotta_Olio_oliva,
	physCilindro,
	teflonOpticalSurface);

I haven’t done a syntax check on that code but I added comments so that you get the general idea.
Hope this helps!
Best
William

1 Like

Thanks for the big reply and so well written! I just have one question.

For Water and Oil a put the vector Transmittance because i need to take into account how many photons are absorbed in the medium (water and oil).

In you reply, i understand which property give to surface and which to the material and I see that the Transmittance for OIl and Water are not set.

Since I need to set them, i need to define two new Optical Surface? How?

So many thanks @wsetterb

Ah, I understand why you had the surface between the oil and water originally now.

If you want to account for absorption at the boundary, you need to set just one surface between the oil and water, but specify the border surface twice like I had in the first reply. The ordering of the volumes matters.

Read the Polished description here and I think you can figure out the rest.

The optical photon documentation has a lot of info that I often check too.

Best
William

1 Like

Wait a second, just to be sure, I have:

1. A block of Teflon with a sphere cut out of it
2. Part of the sphere filled with water
3. Part of the sphere filled with oil.

So, I need:

A G4OpticalSurface for Teflon-Water, G4OpticalSurface for Teflon-OIl and a G4OpticalSurface for OIl-Water.

Then i Also need two G4Logical Border for each surface? I’m bit confused…

Otherwise, @wsetterb a part from property, maybe this code was correct?

Yes the code you initially posted is mostly right aside from setting some properties. However, there is one other difference: you only need one G4OpticalSurface for the Teflon interface. Then you need two G4LogicalBorderSurfaces between oil/Teflon and water/Teflon and you can reuse the G4OpticalSurface.

Then you need the G4OpticalSurface and a G4LogicalBorderSurface between oil/water like you had.

For each of the border surfaces, if you want the behavior to be the same in both directions you can define them like this:

auto* surf = new G4LogicalBorderSurface ...
// ...
std::string name = // ...
// NB: do (vol1, vol2) and (vol2, vol1) because the order is important
(void) new G4LogicalBorderSurface(name + "-border-surf-out-in", vol1, vol2, surf);
(void) new G4LogicalBorderSurface(name + "-border-surf-in-out", vol2, vol1, surf);
1 Like

Yes. The best way to make sure it gets done is to open a bug report. (A git PR would be better, but I don’t believe we have those for documentation). Choose ‘Documentation’ as the category.

1 Like

Maybe we are converging, I mean, I agree with you for the teflon/water-oil question. But if I attach the transmittance property to the surface for the teflon, where can I attach the transmittance property for oil and water? In the following code i tried to do that, but I’m not sure that it is the correct way.

Then, I want the behaviour in both directions also for the surface water-oil, so I need one G4OpticalSurface and two G4LogicalBorder , right? In the following code I did it.

Then, same question as before, where can I link the transmittance property for oil and water to this surface? In the following code i tried to do that, but I’m not sure that it is the correct way.

Here you can find the new code with your advice:

   //first surface
  G4OpticalSurface* TeflonOpticalSurface = new G4OpticalSurface("TeflonSurface");
  

	 TeflonOpticalSurface->SetType(dielectric_dielectric);
	 TeflonOpticalSurface->SetModel(unified);
	 TeflonOpticalSurface->SetFinish(groundfrontpainted);


 //Siccome voglio lo stesso andamento da e verso il teflon, ho biogno di due G4BorderSurface in cui inverto i volumi di ptfe e acqua 
 /*G4LogicalBorderSurface* WaterTeflonSurface =*/ new
    G4LogicalBorderSurface("LSB_WaterTeflonSurface", physSferaIntegratrice, physCilindro, TeflonOpticalSurface);
    /*G4LogicalBorderSurface* TeflonWaterSurface =*/ new
    G4LogicalBorderSurface("LSB_TeflonWaterSurface", physCilindro, physSferaIntegratrice, TeflonOpticalSurface);

  
  //define MPTs for Teflon and the interface _separately_
  G4MaterialPropertiesTable* TEFLON_MPT = new G4MaterialPropertiesTable();
  G4MaterialPropertiesTable* TeflonInterfaceMpt = new G4MaterialPropertiesTable();


  //vettore energia relativo a 200 nm - 400 nm
  std::vector<G4double> energy = {3.0995*eV, 3.1073*eV, 3.1151*eV, 3.1229*eV, 3.1308*eV, 3.1387*eV, 3.1467*eV, 3.1547*eV, 3.1628*eV, 3.1708*eV,
                                  3.1790*eV, 3.1871*eV, 3.1954*eV, 3.2036*eV, 3.2119*eV, 3.2203*eV, 3.2286*eV, 3.2371*eV, 3.2455*eV, 3.2541*eV, 
                                  3.2626*eV, 3.2712*eV, 3.2799*eV, 3.2886*eV, 3.2973*eV, 3.3061*eV, 3.3150*eV, 3.3239*eV, 3.3328*eV, 3.3418*eV, 
                                  3.3508*eV, 3.3599*eV, 3.3690*eV, 3.3782*eV, 3.3874*eV, 3.3967*eV, 3.4060*eV, 3.4154*eV, 3.4249*eV, 3.4343*eV, 
                                  3.4439*eV, 3.4535*eV, 3.4631*eV, 3.4728*eV, 3.4826*eV, 3.4924*eV, 3.5023*eV, 3.5122*eV, 3.5222*eV, 3.5322*eV, 
                                  3.5423*eV, 3.5524*eV, 3.5626*eV, 3.5729*eV, 3.5832*eV, 3.5936*eV, 3.6041*eV, 3.6146*eV, 3.6251*eV, 3.6358*eV, 
                                  3.6465*eV, 3.6572*eV, 3.6680*eV, 3.6789*eV, 3.6899*eV, 3.7009*eV, 3.7120*eV, 3.7231*eV, 3.7343*eV, 3.7456*eV, 
                                  3.7570*eV, 3.7684*eV, 3.7799*eV, 3.7914*eV, 3.8031*eV, 3.8148*eV, 3.8265*eV, 3.8384*eV, 3.8503*eV, 3.8623*eV, 
                                  3.8744*eV, 3.8865*eV, 3.8987*eV, 3.9110*eV, 3.9234*eV, 3.9359*eV, 3.9484*eV, 3.9610*eV, 3.9737*eV, 3.9865*eV, 
                                  3.9994*eV, 4.0123*eV, 4.0253*eV, 4.0384*eV, 4.0516*eV, 4.0649*eV, 4.0783*eV, 4.0917*eV, 4.1053*eV, 4.1189*eV, 
                                  4.1327*eV, 4.1465*eV, 4.1604*eV, 4.1744*eV, 4.1885*eV, 4.2027*eV, 4.2170*eV, 4.2314*eV, 4.2459*eV, 4.2605*eV, 
                                  4.2752*eV, 4.2900*eV, 4.3049*eV, 4.3199*eV, 4.3350*eV, 4.3502*eV, 4.3655*eV, 4.3809*eV, 4.3965*eV, 4.4121*eV, 
                                  4.4279*eV, 4.4437*eV, 4.4597*eV, 4.4758*eV, 4.4920*eV, 4.5084*eV, 4.5248*eV, 4.5414*eV, 4.5581*eV, 4.5749*eV, 
                                  4.5919*eV, 4.6089*eV, 4.6261*eV, 4.6434*eV, 4.6609*eV, 4.6785*eV, 4.6962*eV, 4.7141*eV, 4.7321*eV, 4.7502*eV, 
                                  4.7685*eV, 4.7869*eV, 4.8054*eV, 4.8241*eV, 4.8430*eV, 4.8620*eV, 4.8811*eV, 4.9004*eV, 4.9198*eV, 4.9394*eV, 
                                  4.9592*eV};
  //ref: https://aip.scitation.org/doi/10.1063/1.1808916                                
  std::vector<G4double> trasmittance = {0.0101, 0.0101, 0.0103, 0.0103, 0.0103, 0.0103, 0.0104, 0.0104, 0.0107, 0.0107, 
                                        0.0107, 0.0107, 0.0107, 0.0108, 0.0108, 0.0108, 0.0108, 0.0109, 0.0109, 0.0109, 
                                        0.0109, 0.0112, 0.0112, 0.0112, 0.0112, 0.0112, 0.0113, 0.0113, 0.0113, 0.0113, 
                                        0.0115, 0.0115, 0.0115, 0.0115, 0.0115, 0.0116, 0.0116, 0.0116, 0.0116, 0.0117, 
                                        0.0117, 0.0117, 0.0117, 0.0117, 0.0117, 0.0120, 0.0120, 0.0120, 0.0120, 0.0120, 
                                        0.0121, 0.0121, 0.0123, 0.0123, 0.0124, 0.0124, 0.0124, 0.0124, 0.0127, 0.0127, 
                                        0.0127, 0.0128, 0.0128, 0.0129, 0.0129, 0.0130, 0.0130, 0.0132, 0.0132, 0.0132, 
                                        0.0133, 0.0133, 0.0134, 0.0134, 0.0136, 0.0136, 0.0137, 0.0137, 0.0137, 0.0137, 
                                        0.0140, 0.0140, 0.0140, 0.0141, 0.0141, 0.0142, 0.0142, 0.0144, 0.0144, 0.0145, 
                                        0.0145, 0.0146, 0.0146, 0.0146, 0.0149, 0.0149, 0.0150, 0.0150, 0.0152, 0.0152, 
                                        0.0158, 0.0158, 0.0161, 0.0161, 0.0171, 0.0179, 0.0179, 0.0188, 0.0188, 0.0200, 
                                        0.0200, 0.0210, 0.0210, 0.0220, 0.0220, 0.0232, 0.0248, 0.0248, 0.0256, 0.0256, 
                                        0.0273, 0.0273, 0.0286, 0.0286, 0.0296, 0.0296, 0.0311, 0.0311, 0.0324, 0.0339, 
                                        0.0339, 0.0352, 0.0352, 0.0372, 0.0372, 0.0380, 0.0380, 0.0398, 0.0398, 0.0414, 
                                        0.0427, 0.0427, 0.0441, 0.0441, 0.0457, 0.0457, 0.0473, 0.0473, 0.0482, 0.0482, 
                                        0.0492};
  //ref: https://www.mdpi.com/2073-4360/12/8/1640
  std::vector<G4double> rindex_teflon = {1.3570, 1.3570, 1.3570, 1.3570, 1.3570, 1.3600, 1.3600, 1.3600, 1.3630, 1.3630, 
                                         1.3630, 1.3630, 1.3630, 1.3630, 1.3630, 1.3630, 1.3630, 1.3630, 1.3630, 1.3630, 
                                         1.3630, 1.3660, 1.3660, 1.3630, 1.3630, 1.3660, 1.3660, 1.3660, 1.3710, 1.3710, 
                                         1.3740, 1.3740, 1.3740, 1.3740, 1.3740, 1.3740, 1.3740, 1.3740, 1.3740, 1.3740, 
                                         1.3740, 1.3740, 1.3740, 1.3740, 1.3740, 1.3740, 1.3740, 1.3750, 1.3750, 1.3750, 
                                         1.3760, 1.3760, 1.3790, 1.3790, 1.3820, 1.3820, 1.3820, 1.3820, 1.3820, 1.3820, 
                                         1.3820, 1.3820, 1.3820, 1.3820, 1.3820, 1.3820, 1.3820, 1.3880, 1.3880, 1.3900, 
                                         1.3900, 1.3900, 1.3900, 1.3900, 1.3900, 1.3900, 1.3900, 1.3900, 1.3930, 1.3930, 
                                         1.3930, 1.3930, 1.3930, 1.3940, 1.3940, 1.3940, 1.3960, 1.3960, 1.3960, 1.3980, 
                                         1.3980, 1.3980, 1.3990, 1.3990, 1.3990, 1.4040, 1.4070, 1.4070, 1.4070, 1.4070, 
                                         1.4070, 1.4070, 1.4070, 1.4070, 1.4100, 1.4100, 1.4150, 1.4180, 1.4180, 1.4180, 
                                         1.4180, 1.4180, 1.4180, 1.4180, 1.4180, 1.4180, 1.4180, 1.4200, 1.4230, 1.4230, 
                                         1.4230, 1.4230, 1.4230, 1.4230, 1.4260, 1.4260, 1.4290, 1.4290, 1.4310, 1.4340, 
                                         1.4340, 1.4340, 1.4340, 1.4370, 1.4370, 1.4420, 1.4420, 1.4420, 1.4420, 1.4420, 
                                         1.4420, 1.4420, 1.4450, 1.4450, 1.4480, 1.4480, 1.4510, 1.4510, 1.4510, 1.4510,
                                         1.4530};
  //valore messo al fine di non avere fotoni al di fuori della sfera
  std::vector<G4double> absorption = {1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 
                                      1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 
                                      1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 
                                      1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 
                                      1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 
                                      1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 
                                      1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 
                                      1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 
                                      1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 
                                      1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 
                                      1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 
                                      1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 
                                      1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 
                                      1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 
                                      1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um,
                                      1.0000*um};       


/*

However, in case of a surface between two dielectrics, the result is not as the variable name suggests: The photons are absorbed 
with a probability of 1 %−r, where r is the specified “reflectivity” value. The remaining photons are then reflected/refracted 
according to the Fresnel equation. Thus, in this case, the REFLECTIVITY variable simulates something like absorbing dirt on the surface. 
To specify the reflectivity of a surface between two dielectrics, the TRANSMITTANCE variable has to be used, where the reflectivity R 
derives from the transmittance T by R = 1 % − T . One should also note that Geant4 does not perform any optical process at a surface 
between two dielectrics that consist of the same material. Per tal motivo il parametro di riflettività non viene usato. 
Si usa la trasmittanza. Il parametro di absorption lo tiri fuori dal grafico di assorbanza usando ROOT e https://apps.automeris.io/wpd/

*/

  
  //only set RINDEX and ABSLENGTH for the material
  TEFLON_MPT->AddProperty("RINDEX", energy, rindex_teflon);
  TEFLON_MPT->AddProperty("ABSLENGTH", energy, absorption);
  
  
  //these properties correspond to surfaces; set them separately.
  //see https://geant4-userdoc.web.cern.ch/UsersGuides/ForApplicationDeveloper/html/TrackingAndPhysics/physicsProcess.html#id9
  TeflonInterfaceMpt->AddProperty("TRANSMITTANCE", energy, trasmittance);
  TeflonInterfaceMpt->AddProperty("RINDEX", energy, rindex_teflon);


  //qui imposti le proprietà del materiale
  teflon_mat->SetMaterialPropertiesTable(TEFLON_MPT);
  
  //here we set the properties to the table defined *only for the interface
  TeflonOpticalSurface->SetMaterialPropertiesTable(TeflonInterfaceMpt);
  
  
  G4MaterialPropertiesTable* Water_MPT = new G4MaterialPropertiesTable();
  G4MaterialPropertiesTable* WaterInterfaceMpt = new G4MaterialPropertiesTable();

  //ref: https://refractiveindex.info/?shelf=main&book=H2O&page=Hale
  std::vector<G4double> rindex_water = {1.3390, 1.3391, 1.3392, 1.3392, 1.3393, 1.3394, 1.3395, 1.3396, 1.3396, 1.3397, 
                                        1.3398, 1.3399, 1.3400, 1.3400, 1.3401, 1.3402, 1.3403, 1.3434, 1.3404, 1.3405, 
                                        1.3406, 1.3407, 1.3408, 1.3408, 1.3409, 1.3410, 1.3411, 1.3412, 1.3412, 1.3413, 
                                        1.3414, 1.3415, 1.3416, 1.3416, 1.3417, 1.3418, 1.3419, 1.3420, 1.3420, 1.3421, 
                                        1.3422, 1.3423, 1.3424, 1.3424, 1.3425, 1.3426, 1.3427, 1.3428, 1.3428, 1.3429, 
                                        1.3430, 1.3431, 1.3432, 1.3434, 1.3435, 1.3436, 1.3437, 1.3438, 1.3440, 1.3441, 
                                        1.3442, 1.3443, 1.3444, 1.3446, 1.3447, 1.3448, 1.3449, 1.3450, 1.3452, 1.3453, 
                                        1.3454, 1.3455, 1.3456, 1.3458, 1.3459, 1.3460, 1.3461, 1.3462, 1.3464, 1.3465, 
                                        1.3466, 1.3467, 1.3468, 1.3470, 1.3471, 1.3472, 1.3473, 1.3474, 1.3476, 1.3477, 
                                        1.3478, 1.3479, 1.3480, 1.3482, 1.3483, 1.3484, 1.3485, 1.3486, 1.3488, 1.3489, 
                                        1.3490, 1.3492, 1.3494, 1.3496, 1.3498, 1.3500, 1.3502, 1.3504, 1.3506, 1.3508, 
                                        1.3510, 1.3512, 1.3514, 1.3516, 1.3518, 1.3520, 1.3522, 1.3524, 1.3526, 1.3528, 
                                        1.3530, 1.3532, 1.3534, 1.3536, 1.3538, 1.3540, 1.3543, 1.3546, 1.3550, 1.3553, 
                                        1.3556, 1.3559, 1.3562, 1.3566, 1.3569, 1.3572, 1.3575, 1.3578, 1.3582, 1.3585, 
                                        1.3588, 1.3591, 1.3594, 1.3598, 1.3601, 1.3604, 1.3607, 1.3610, 1.3614, 1.3617, 
                                        1.3620};
  //ref: https://sci-hub.ru/https://doi.org/10.1039/C5RA11502G
  std::vector<G4double> absorption_water = {169.2437*m, 171.3565*m, 173.3922*m, 175.3392*m, 177.1855*m, 178.9191*m, 180.5284*m, 182.0019*m, 183.3286*m, 184.4981*m, 
                                            185.5008*m, 186.3279*m, 186.9718*m, 187.4259*m, 187.6853*m, 187.7459*m, 187.6056*m, 187.2635*m, 186.7204*m, 185.9783*m, 
                                            185.0412*m, 183.9140*m, 182.6033*m, 181.1166*m, 179.4627*m, 177.6512*m, 175.6927*m, 173.5981*m, 171.3789*m, 169.0471*m, 
                                            166.6146*m, 164.0935*m, 161.4955*m, 158.8324*m, 156.1154*m, 153.3555*m, 150.5630*m, 147.7477*m, 144.9188*m, 142.0850*m, 
                                            139.2541*m, 136.4334*m, 133.6296*m, 130.8485*m, 128.0956*m, 125.3755*m, 122.6924*m, 120.0499*m, 117.4511*m, 114.8986*m, 
                                            112.3945*m, 109.9407*m, 107.5384*m, 105.1887*m, 102.8924*m, 100.6498*m, 98.4612*m, 96.3264*m, 94.2454*m, 92.2177*m, 
                                            90.2426*m, 88.3197*m, 86.4480*m, 84.6266*m, 82.8546*m, 81.1310*m, 79.4546*m, 77.8243*m, 76.2389*m, 74.6973*m, 
                                            73.1983*m, 71.7405*m, 70.3228*m, 68.9440*m, 67.6029*m, 66.2981*m, 65.0286*m, 63.7931*m, 62.5905*m, 61.4196*m, 
                                            60.2794*m, 59.1686*m, 58.0863*m, 57.0314*m, 56.0028*m, 54.9996*m, 54.0207*m, 53.0653*m, 52.1324*m, 51.2211*m, 
                                            50.3305*m, 49.4598*m, 48.6082*m, 47.7749*m, 46.9592*m, 46.1602*m, 45.3773*m, 44.6097*m, 43.8569*m, 43.1182*m, 
                                            42.3929*m, 41.6805*m, 40.9804*m, 40.2920*m, 39.6149*m, 38.9486*m, 38.2924*m, 37.6461*m, 37.0092*m, 36.3812*m, 
                                            35.7618*m, 35.1506*m, 34.5473*m, 33.9515*m, 33.3630*m, 32.7814*m, 32.2065*m, 31.6380*m, 31.0758*m, 30.5195*m, 
                                            29.9691*m, 29.4244*m, 28.8852*m, 28.3514*m, 27.8229*m, 27.2996*m, 26.7814*m, 26.2682*m, 25.7600*m, 25.2567*m, 
                                            24.7584*m, 24.2650*m, 23.7765*m, 23.2930*m, 22.8144*m, 22.3408*m, 21.8723*m, 21.4088*m, 20.9505*m, 20.4973*m, 
                                            20.0495*m, 19.6070*m, 19.1699*m, 18.7383*m, 18.3122*m, 17.8918*m, 17.4771*m, 17.0682*m, 16.6652*m, 16.2682*m, 
                                            15.8771*m};
  //ref: https://refractiveindex.info/?shelf=main&book=H2O&page=Hale
  std::vector<G4double> trasmittance_water = {1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 
                                              1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 
                                              1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 
                                              1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 
                                              1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 
                                              1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 
                                              1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 
                                              1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 
                                              1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 
                                              1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 
                                              1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 
                                              1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 
                                              1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 
                                              1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 
                                              1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 
                                              1.0000}; 
  
  
  //qui si impostano le proprietà del materiale
  Water_MPT->AddProperty("RINDEX", energy, rindex_water);
  Water_MPT->AddProperty("ABSLENGTH", energy, absorption_water);

  //qui si impostano le proprietà della superficie
  WaterInterfaceMpt->AddProperty("TRANSMITTANCE", energy, trasmittance_water);
  WaterInterfaceMpt->AddProperty("RINDEX", energy, rindex_water);
  
  
  water_mat->SetMaterialPropertiesTable(Water_MPT);

  TeflonOpticalSurface->SetMaterialPropertiesTable(WaterInterfaceMpt);


  //Siccome voglio lo stesso andamento da e verso il teflon, ho biogno di due G4BorderSurface in cui inverto i volumi di ptfe e olio
 /*G4LogicalBorderSurface* TeflonOilSurface =*/ new
    G4LogicalBorderSurface("LSB_TeflonOilSurface", physCilindro, physCalotta_Olio_oliva, TeflonOpticalSurface);
 /*G4LogicalBorderSurface* PolWaterSurface =*/ new
    G4LogicalBorderSurface("LSB_OilTeflonSurface", physCalotta_Olio_oliva, physCilindro, TeflonOpticalSurface);
 
  /*

  Dato che è impossibile trovare ricerche in letteratura per quanto riguarda i parametri ottici dell'olio, essi sono stati
  ricavati tramite diverse formule. L'indice di rifrazione tramite la formula di Cauchy, ref: 
  https://www.horiba.com/fra/scientific/technologies/spectroscopic-ellipsometry/cauchy-dispersion-module/ mentre i parametri 
  sono stati presi dalla ref https://www.worldscientific.com/doi/10.1142/S1793545821400101 
  La formula della transmittance è stata anch'essa ricavata mediante: 

  */

  std::vector<G4double> rindex_olio_oliva = {1.4114, 1.4115, 1.4116, 1.4118, 1.4119, 1.4120, 1.4121, 1.4122, 1.4124, 1.4125, 
                                             1.4126, 1.4127, 1.4129, 1.4130, 1.4131, 1.4133, 1.4134, 1.4135, 1.4137, 1.4138, 
                                             1.4139, 1.4141, 1.4142, 1.4143, 1.4145, 1.4146, 1.4148, 1.4149, 1.4150, 1.4152, 
                                             1.4153, 1.4155, 1.4156, 1.4158, 1.4159, 1.4161, 1.4162, 1.4164, 1.4165, 1.4167, 
                                             1.4169, 1.4170, 1.4172, 1.4173, 1.4175, 1.4177, 1.4178, 1.4180, 1.4182, 1.4183, 
                                             1.4185, 1.4187, 1.4189, 1.4190, 1.4192, 1.4194, 1.4196, 1.4198, 1.4199, 1.4201, 
                                             1.4203, 1.4205, 1.4207, 1.4209, 1.4211, 1.4213, 1.4215, 1.4217, 1.4219, 1.4221, 
                                             1.4223, 1.4225, 1.4227, 1.4229, 1.4231, 1.4233, 1.4236, 1.4238, 1.4240, 1.4242, 
                                             1.4244, 1.4247, 1.4249, 1.4251, 1.4254, 1.4256, 1.4258, 1.4261, 1.4263, 1.4266, 
                                             1.4268, 1.4270, 1.4273, 1.4276, 1.4278, 1.4281, 1.4283, 1.4286, 1.4289, 1.4291, 
                                             1.4294, 1.4297, 1.4300, 1.4302, 1.4305, 1.4308, 1.4311, 1.4314, 1.4317, 1.4320, 
                                             1.4323, 1.4326, 1.4329, 1.4332, 1.4335, 1.4338, 1.4341, 1.4345, 1.4348, 1.4351, 
                                             1.4355, 1.4358, 1.4361, 1.4365, 1.4368, 1.4372, 1.4375, 1.4379, 1.4382, 1.4386, 
                                             1.4390, 1.4394, 1.4397, 1.4401, 1.4405, 1.4409, 1.4413, 1.4417, 1.4421, 1.4425, 
                                             1.4429, 1.4433, 1.4438, 1.4442, 1.4446, 1.4451, 1.4455, 1.4460, 1.4464, 1.4469, 
                                             1.4473};
  //ref: https://www.scielo.org.mx/scielo.php?pid=S1665-64232020000600333&script=sci_arttext
  std::vector<G4double> absorption_olio_oliva = {0.3561*mm, 0.4272*mm, 0.4717*mm, 0.4613*mm, 0.4735*mm, 0.4831*mm, 0.4902*mm, 0.4970*mm, 0.5045*mm, 0.5136*mm, 
                                                 0.5219*mm, 0.5297*mm, 0.5382*mm, 0.5467*mm, 0.5559*mm, 0.5637*mm, 0.5714*mm, 0.5790*mm, 0.5831*mm, 0.5882*mm, 
                                                 0.5942*mm, 0.5981*mm, 0.6024*mm, 0.6050*mm, 0.6079*mm, 0.6124*mm, 0.6143*mm, 0.6180*mm, 0.6219*mm, 0.6242*mm, 
                                                 0.6289*mm, 0.6321*mm, 0.6341*mm, 0.6361*mm, 0.6386*mm, 0.6435*mm, 0.6460*mm, 0.6456*mm, 0.6485*mm, 0.6494*mm, 
                                                 0.6472*mm, 0.6452*mm, 0.6439*mm, 0.6382*mm, 0.6345*mm, 0.6333*mm, 0.6281*mm, 0.6169*mm, 0.6250*mm, 0.5879*mm, 
                                                 0.5147*mm, 0.5107*mm, 0.5565*mm, 0.5865*mm, 0.5682*mm, 0.5571*mm, 0.5528*mm, 0.5459*mm, 0.5350*mm, 0.5252*mm, 
                                                 0.5139*mm, 0.5040*mm, 0.4965*mm, 0.4880*mm, 0.4773*mm, 0.4619*mm, 0.4468*mm, 0.4367*mm, 0.4243*mm, 0.4092*mm, 
                                                 0.3968*mm, 0.3871*mm, 0.3731*mm, 0.3687*mm, 0.3686*mm, 0.3621*mm, 0.3551*mm, 0.3529*mm, 0.3483*mm, 0.3372*mm, 
                                                 0.3255*mm, 0.3160*mm, 0.3088*mm, 0.3040*mm, 0.3005*mm, 0.2958*mm, 0.2916*mm, 0.2888*mm, 0.2869*mm, 0.2885*mm, 
                                                 0.2890*mm, 0.2846*mm, 0.2774*mm, 0.2714*mm, 0.2639*mm, 0.2570*mm, 0.2534*mm, 0.2503*mm, 0.2541*mm, 0.2427*mm, 
                                                 0.2237*mm, 0.2433*mm, 0.2553*mm, 0.2514*mm, 0.2528*mm, 0.2530*mm, 0.2549*mm, 0.2564*mm, 0.2562*mm, 0.2571*mm, 
                                                 0.2574*mm, 0.2579*mm, 0.2589*mm, 0.2592*mm, 0.2596*mm, 0.2599*mm, 0.2605*mm, 0.2617*mm, 0.2626*mm, 0.2632*mm, 
                                                 0.2636*mm, 0.2639*mm, 0.2640*mm, 0.2641*mm, 0.2647*mm, 0.2650*mm, 0.2646*mm, 0.2648*mm, 0.2650*mm, 0.2650*mm, 
                                                 0.2655*mm, 0.2656*mm, 0.2655*mm, 0.2656*mm, 0.2655*mm, 0.2657*mm, 0.2653*mm, 0.2650*mm, 0.2652*mm, 0.2634*mm, 
                                                 0.2618*mm, 0.2611*mm, 0.2598*mm, 0.2597*mm, 0.2597*mm, 0.2599*mm, 0.2603*mm, 0.2603*mm, 0.2646*mm, 0.2592*mm, 
                                                 0.2467*mm};

  std::vector<G4double> trasmittance_olio_oliva = {0.9106, 0.9106, 0.9106, 0.9105, 0.9105, 0.9104, 0.9104, 0.9104, 0.9103, 0.9103, 
                                                   0.9102, 0.9102, 0.9102, 0.9101, 0.9101, 0.9100, 0.9100, 0.9100, 0.9099, 0.9099, 
                                                   0.9098, 0.9098, 0.9097, 0.9097, 0.9097, 0.9096, 0.9096, 0.9095, 0.9095, 0.9094, 
                                                   0.9094, 0.9093, 0.9093, 0.9092, 0.9092, 0.9091, 0.9091, 0.9090, 0.9090, 0.9089, 
                                                   0.9089, 0.9088, 0.9088, 0.9087, 0.9087, 0.9086, 0.9086, 0.9085, 0.9085, 0.9084, 
                                                   0.9084, 0.9083, 0.9082, 0.9082, 0.9081, 0.9081, 0.9080, 0.9080, 0.9079, 0.9078, 
                                                   0.9078, 0.9077, 0.9077, 0.9076, 0.9075, 0.9075, 0.9074, 0.9073, 0.9073, 0.9072, 
                                                   0.9071, 0.9071, 0.9070, 0.9069, 0.9069, 0.9068, 0.9067, 0.9067, 0.9066, 0.9065, 
                                                   0.9065, 0.9064, 0.9063, 0.9062, 0.9062, 0.9061, 0.9060, 0.9059, 0.9059, 0.9058, 
                                                   0.9057, 0.9056, 0.9055, 0.9055, 0.9054, 0.9053, 0.9052, 0.9051, 0.9050, 0.9049, 
                                                   0.9049, 0.9048, 0.9047, 0.9046, 0.9045, 0.9044, 0.9043, 0.9042, 0.9041, 0.9040, 
                                                   0.9039, 0.9038, 0.9037, 0.9036, 0.9035, 0.9034, 0.9033, 0.9032, 0.9031, 0.9030, 
                                                   0.9029, 0.9028, 0.9027, 0.9026, 0.9025, 0.9024, 0.9022, 0.9021, 0.9020, 0.9019, 
                                                   0.9018, 0.9016, 0.9015, 0.9014, 0.9013, 0.9011, 0.9010, 0.9009, 0.9008, 0.9006, 
                                                   0.9005, 0.9004, 0.9002, 0.9001, 0.8999, 0.8998, 0.8997, 0.8995, 0.8994, 0.8992, 
                                                   0.8991}; 

  
  G4MaterialPropertiesTable* Olio_MPT = new G4MaterialPropertiesTable();
  G4MaterialPropertiesTable* OlioInterface_Mpt = new G4MaterialPropertiesTable();

  
  //qui imposto le proprietà del materiale
  Olio_MPT->AddProperty("RINDEX", energy, rindex_olio_oliva);
  Olio_MPT->AddProperty("ABSLENGTH", energy, absorption_olio_oliva);

  //qui imposto le proprietà della superfice
  OlioInterface_Mpt->AddProperty("TRANSMITTANCE", energy, trasmittance_olio_oliva);
  OlioInterface_Mpt->AddProperty("RINDEX", energy, rindex_olio_oliva);


  Olio_Oliva->SetMaterialPropertiesTable(Olio_MPT);


  TeflonOpticalSurface->SetMaterialPropertiesTable(OlioInterface_Mpt);
  

  //second surface
  G4OpticalSurface* WaterOilOpticalSurface = new G4OpticalSurface("WaterOilSurface");
  

     WaterOilOpticalSurface->SetType(dielectric_dielectric);
     WaterOilOpticalSurface->SetModel(unified);
     WaterOilOpticalSurface->SetFinish(polished);


  //Siccome voglio lo stesso andamento, ho biogno di due G4BorderSurface in cui inverto i volumi di olio e acqua 
 /*G4LogicalBorderSurface* WaterOilSurface =*/ new
    G4LogicalBorderSurface("LSB_WaterOIlSurface", physSferaIntegratrice, physCalotta_Olio_oliva, WaterOilOpticalSurface);
 /*G4LogicalBorderSurface* OilWaterSurface =*/ new
    G4LogicalBorderSurface("LSB_OilWaterSurface", physCalotta_Olio_oliva, physSferaIntegratrice, WaterOilOpticalSurface);
  

    WaterOilOpticalSurface->SetMaterialPropertiesTable(OlioInterface_Mpt);
    WaterOilOpticalSurface->SetMaterialPropertiesTable(WaterInterfaceMpt);

What do you think? For you the all syntax is now correct?

This is almost all good now. This is another long post but I hope it’s helpful.

Comments on the code

  • The TeflonOpticalSurface should not be used for the oil/water interface. I suggest making a new G4OpticalSurface for that interface. Sorry about that confusion.
  • The TeflonOpticalSurface should be re-used for the oil to Teflon interface.
  • These lines are not correct:

You shouldn’t set the property table like that twice. It doesn’t really make sense because you are overwriting the property. This happens a couple times elsewhere but I think I understand why—you want the oil/water vs water/oil interface to behave differently. I think there is a proper way to do this so I will describe it below.

Ideas to try

I think I am almost understanding what you are looking for now; sorry it took so long. Here is an updated set of ideas and you can implement them in code.

  • You want to count optical photons absorbed into the oil. You want water/oil to be polished, and oil/Teflon and water/Teflon to be diffuse.

  • You will need three G4OpticalSurfaces. One defines the transition into Teflon. One defines the transition into water. The third defines the transition into oil.

  • You will need to call new G4LogicalBorderSurface six times in total:

    • once to define Teflon → water
    • once to define water → Teflon
    • once to define Teflon → oil
    • once to define oil → Teflon
    • once to define water → oil
    • once to define oil → water
  • The reason you call it six times is because the volume ordering matters. So for water to oil and oil to water, it might look like this:

auto* waterOpticalSurface = // ... add RINDEX
auto* oilOpticalSurface = // ... add RINDEX, TRANSMITTANCE

// oil to water
new G4LogicalBorderSurface("oil-to-water", oilPv, waterPv, waterOpticalSurface);
// water to oil
// Nota bene: the order of physical volumes, and the optical surfaces, has changed.
new G4LogicalBorderSurface("water-to-oil", waterPv, oilPv, oilOpticalSurface);

Notice how the surface changes as the volume ordering changes. I think this is what you were trying to achieve by setting the material property table multiple times. Correct?

Please let me know if you have further questions. Once you get things working I’d love to see some preliminary results!

1 Like

Hi @wsetterb , oh yeah, your post are helping me so much!

Reply on: Comments on the code

  • If you see, i don’t use the TeflonOpticalSurface for the oil/water interfaces, i created a new G4OpticalSurface called WaterOilOpticalSurface

  • I re-use the TeflonOpticalSurface for the oil/teflon interface, maybe i did it wrong?

  • I didn’t know that, i will follow your advices.

Reply on: Ideas to try

It is my fault, i will describe briefly what I want to do: The idea is to write a simulation in order to make an estimation of absorbance of oil in the water. To do that, i create a integrating sphere where, for every energy, I shoot 1e6 optical photon inside it. For every run i store the number of optical photon died in my detector (it is a cilinder of Silicon put inside the integrating sphere with a diameter of 600 um). In that way I can make a spectrum of Absorbance = Ln(n_died_detector/1e6) over the range of 250 - 400 nm.

Having said that:

  • I count the photon that arrives on the detector (Yellow disc in the pics, and yes, in the RunAction.cc I also count where all the photons died (water, oil, teflon or detector).

  • As you can see in the code I have already defined two surfaces, but from your answers I realised that there must be three and you have already given me an idea of how to do this. I will correct the code

  • Ok, but I have already done this correctly or am I wrong? Then, why in your WaterOpticalSurface I can’t add the Transmittacne as you write for the OilOpticalSurface ?

But now I understand the correct way to use them, I hope!

Exactly, you said it right. This way I can set the various transmittance properties on each surface.

And of course, when this part of code is finish, i will post here for you and all the reader the preliminary results!

New code:

Here i will post the new code written thanks to your advices:

  /*

  You will need three G4OpticalSurfaces. One defines the transition into Teflon. One defines the transition into water. 
  The third defines the transition into oil. For this reason, You will need to call new G4LogicalBorderSurface six times in total:
  
    once to define Teflon → water
    once to define water → Teflon
    once to define Teflon → oil
    once to define oil → Teflon
    once to define water → oil
    once to define oil → water

   The reason you call it six times is because the volume ordering matters.


   */

  G4OpticalSurface* TeflonOpticalSurface = new G4OpticalSurface("TeflonSurface");
  

	 TeflonOpticalSurface->SetType(dielectric_dielectric);
	 TeflonOpticalSurface->SetModel(unified);
	 TeflonOpticalSurface->SetFinish(groundfrontpainted);

  G4OpticalSurface* WaterOpticalSurface = new G4OpticalSurface("WaterSurface");


     WaterOpticalSurface->SetType(dielectric_dielectric);
     WaterOpticalSurface->SetModel(unified);
     WaterOpticalSurface->SetFinish(groundfrontpainted);


 /*G4LogicalBorderSurface* WaterTeflonSurface =*/ new
    G4LogicalBorderSurface("LSB_WaterTeflonSurface", physSferaIntegratrice, physCilindro, TeflonOpticalSurface);
    /*G4LogicalBorderSurface* TeflonWaterSurface =*/ new
    G4LogicalBorderSurface("LSB_TeflonWaterSurface", physCilindro, physSferaIntegratrice, WaterOpticalSurface);

  
  //define MPTs for Teflon and the interface _separately_
  G4MaterialPropertiesTable* TEFLON_MPT = new G4MaterialPropertiesTable();
  G4MaterialPropertiesTable* TeflonInterfaceMpt = new G4MaterialPropertiesTable();


  //vettore energia relativo a 250 nm - 400 nm
  std::vector<G4double> energy = {3.0995*eV, 3.1073*eV, 3.1151*eV, 3.1229*eV, 3.1308*eV, 3.1387*eV, 3.1467*eV, 3.1547*eV, 3.1628*eV, 3.1708*eV,
                                  3.1790*eV, 3.1871*eV, 3.1954*eV, 3.2036*eV, 3.2119*eV, 3.2203*eV, 3.2286*eV, 3.2371*eV, 3.2455*eV, 3.2541*eV, 
                                  3.2626*eV, 3.2712*eV, 3.2799*eV, 3.2886*eV, 3.2973*eV, 3.3061*eV, 3.3150*eV, 3.3239*eV, 3.3328*eV, 3.3418*eV, 
                                  3.3508*eV, 3.3599*eV, 3.3690*eV, 3.3782*eV, 3.3874*eV, 3.3967*eV, 3.4060*eV, 3.4154*eV, 3.4249*eV, 3.4343*eV, 
                                  3.4439*eV, 3.4535*eV, 3.4631*eV, 3.4728*eV, 3.4826*eV, 3.4924*eV, 3.5023*eV, 3.5122*eV, 3.5222*eV, 3.5322*eV, 
                                  3.5423*eV, 3.5524*eV, 3.5626*eV, 3.5729*eV, 3.5832*eV, 3.5936*eV, 3.6041*eV, 3.6146*eV, 3.6251*eV, 3.6358*eV, 
                                  3.6465*eV, 3.6572*eV, 3.6680*eV, 3.6789*eV, 3.6899*eV, 3.7009*eV, 3.7120*eV, 3.7231*eV, 3.7343*eV, 3.7456*eV, 
                                  3.7570*eV, 3.7684*eV, 3.7799*eV, 3.7914*eV, 3.8031*eV, 3.8148*eV, 3.8265*eV, 3.8384*eV, 3.8503*eV, 3.8623*eV, 
                                  3.8744*eV, 3.8865*eV, 3.8987*eV, 3.9110*eV, 3.9234*eV, 3.9359*eV, 3.9484*eV, 3.9610*eV, 3.9737*eV, 3.9865*eV, 
                                  3.9994*eV, 4.0123*eV, 4.0253*eV, 4.0384*eV, 4.0516*eV, 4.0649*eV, 4.0783*eV, 4.0917*eV, 4.1053*eV, 4.1189*eV, 
                                  4.1327*eV, 4.1465*eV, 4.1604*eV, 4.1744*eV, 4.1885*eV, 4.2027*eV, 4.2170*eV, 4.2314*eV, 4.2459*eV, 4.2605*eV, 
                                  4.2752*eV, 4.2900*eV, 4.3049*eV, 4.3199*eV, 4.3350*eV, 4.3502*eV, 4.3655*eV, 4.3809*eV, 4.3965*eV, 4.4121*eV, 
                                  4.4279*eV, 4.4437*eV, 4.4597*eV, 4.4758*eV, 4.4920*eV, 4.5084*eV, 4.5248*eV, 4.5414*eV, 4.5581*eV, 4.5749*eV, 
                                  4.5919*eV, 4.6089*eV, 4.6261*eV, 4.6434*eV, 4.6609*eV, 4.6785*eV, 4.6962*eV, 4.7141*eV, 4.7321*eV, 4.7502*eV, 
                                  4.7685*eV, 4.7869*eV, 4.8054*eV, 4.8241*eV, 4.8430*eV, 4.8620*eV, 4.8811*eV, 4.9004*eV, 4.9198*eV, 4.9394*eV, 
                                  4.9592*eV};
  //ref: https://aip.scitation.org/doi/10.1063/1.1808916                                
  std::vector<G4double> trasmittance = {0.0101, 0.0101, 0.0103, 0.0103, 0.0103, 0.0103, 0.0104, 0.0104, 0.0107, 0.0107, 
                                        0.0107, 0.0107, 0.0107, 0.0108, 0.0108, 0.0108, 0.0108, 0.0109, 0.0109, 0.0109, 
                                        0.0109, 0.0112, 0.0112, 0.0112, 0.0112, 0.0112, 0.0113, 0.0113, 0.0113, 0.0113, 
                                        0.0115, 0.0115, 0.0115, 0.0115, 0.0115, 0.0116, 0.0116, 0.0116, 0.0116, 0.0117, 
                                        0.0117, 0.0117, 0.0117, 0.0117, 0.0117, 0.0120, 0.0120, 0.0120, 0.0120, 0.0120, 
                                        0.0121, 0.0121, 0.0123, 0.0123, 0.0124, 0.0124, 0.0124, 0.0124, 0.0127, 0.0127, 
                                        0.0127, 0.0128, 0.0128, 0.0129, 0.0129, 0.0130, 0.0130, 0.0132, 0.0132, 0.0132, 
                                        0.0133, 0.0133, 0.0134, 0.0134, 0.0136, 0.0136, 0.0137, 0.0137, 0.0137, 0.0137, 
                                        0.0140, 0.0140, 0.0140, 0.0141, 0.0141, 0.0142, 0.0142, 0.0144, 0.0144, 0.0145, 
                                        0.0145, 0.0146, 0.0146, 0.0146, 0.0149, 0.0149, 0.0150, 0.0150, 0.0152, 0.0152, 
                                        0.0158, 0.0158, 0.0161, 0.0161, 0.0171, 0.0179, 0.0179, 0.0188, 0.0188, 0.0200, 
                                        0.0200, 0.0210, 0.0210, 0.0220, 0.0220, 0.0232, 0.0248, 0.0248, 0.0256, 0.0256, 
                                        0.0273, 0.0273, 0.0286, 0.0286, 0.0296, 0.0296, 0.0311, 0.0311, 0.0324, 0.0339, 
                                        0.0339, 0.0352, 0.0352, 0.0372, 0.0372, 0.0380, 0.0380, 0.0398, 0.0398, 0.0414, 
                                        0.0427, 0.0427, 0.0441, 0.0441, 0.0457, 0.0457, 0.0473, 0.0473, 0.0482, 0.0482, 
                                        0.0492};
  //ref: https://www.mdpi.com/2073-4360/12/8/1640
  std::vector<G4double> rindex_teflon = {1.3570, 1.3570, 1.3570, 1.3570, 1.3570, 1.3600, 1.3600, 1.3600, 1.3630, 1.3630, 
                                         1.3630, 1.3630, 1.3630, 1.3630, 1.3630, 1.3630, 1.3630, 1.3630, 1.3630, 1.3630, 
                                         1.3630, 1.3660, 1.3660, 1.3630, 1.3630, 1.3660, 1.3660, 1.3660, 1.3710, 1.3710, 
                                         1.3740, 1.3740, 1.3740, 1.3740, 1.3740, 1.3740, 1.3740, 1.3740, 1.3740, 1.3740, 
                                         1.3740, 1.3740, 1.3740, 1.3740, 1.3740, 1.3740, 1.3740, 1.3750, 1.3750, 1.3750, 
                                         1.3760, 1.3760, 1.3790, 1.3790, 1.3820, 1.3820, 1.3820, 1.3820, 1.3820, 1.3820, 
                                         1.3820, 1.3820, 1.3820, 1.3820, 1.3820, 1.3820, 1.3820, 1.3880, 1.3880, 1.3900, 
                                         1.3900, 1.3900, 1.3900, 1.3900, 1.3900, 1.3900, 1.3900, 1.3900, 1.3930, 1.3930, 
                                         1.3930, 1.3930, 1.3930, 1.3940, 1.3940, 1.3940, 1.3960, 1.3960, 1.3960, 1.3980, 
                                         1.3980, 1.3980, 1.3990, 1.3990, 1.3990, 1.4040, 1.4070, 1.4070, 1.4070, 1.4070, 
                                         1.4070, 1.4070, 1.4070, 1.4070, 1.4100, 1.4100, 1.4150, 1.4180, 1.4180, 1.4180, 
                                         1.4180, 1.4180, 1.4180, 1.4180, 1.4180, 1.4180, 1.4180, 1.4200, 1.4230, 1.4230, 
                                         1.4230, 1.4230, 1.4230, 1.4230, 1.4260, 1.4260, 1.4290, 1.4290, 1.4310, 1.4340, 
                                         1.4340, 1.4340, 1.4340, 1.4370, 1.4370, 1.4420, 1.4420, 1.4420, 1.4420, 1.4420, 
                                         1.4420, 1.4420, 1.4450, 1.4450, 1.4480, 1.4480, 1.4510, 1.4510, 1.4510, 1.4510,
                                         1.4530};
  //valore messo al fine di non avere fotoni al di fuori della sfera
  std::vector<G4double> absorption = {1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 
                                      1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 
                                      1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 
                                      1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 
                                      1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 
                                      1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 
                                      1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 
                                      1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 
                                      1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 
                                      1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 
                                      1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 
                                      1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 
                                      1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 
                                      1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 
                                      1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um, 1.0000*um,
                                      1.0000*um};       


/*

However, in case of a surface between two dielectrics, the result is not as the variable name suggests: The photons are absorbed 
with a probability of 1 %−r, where r is the specified “reflectivity” value. The remaining photons are then reflected/refracted 
according to the Fresnel equation. Thus, in this case, the REFLECTIVITY variable simulates something like absorbing dirt on the surface. 
To specify the reflectivity of a surface between two dielectrics, the TRANSMITTANCE variable has to be used, where the reflectivity R 
derives from the transmittance T by R = 1 % − T . One should also note that Geant4 does not perform any optical process at a surface 
between two dielectrics that consist of the same material. Per tal motivo il parametro di riflettività non viene usato. 
Si usa la trasmittanza. Il parametro di absorption lo tiri fuori dal grafico di assorbanza usando ROOT e https://apps.automeris.io/wpd/

*/

  
  //only set RINDEX and ABSLENGTH for the material
  TEFLON_MPT->AddProperty("RINDEX", energy, rindex_teflon);
  TEFLON_MPT->AddProperty("ABSLENGTH", energy, absorption);
  
  
  //these properties correspond to surfaces; set them separately.
  //see https://geant4-userdoc.web.cern.ch/UsersGuides/ForApplicationDeveloper/html/TrackingAndPhysics/physicsProcess.html#id9
  TeflonInterfaceMpt->AddProperty("TRANSMITTANCE", energy, trasmittance);
  TeflonInterfaceMpt->AddProperty("RINDEX", energy, rindex_teflon);


  //qui associ le proprietà del materiale
  teflon_mat->SetMaterialPropertiesTable(TEFLON_MPT);
  
  //here we set the properties to the table defined only for the interface
  TeflonOpticalSurface->SetMaterialPropertiesTable(TeflonInterfaceMpt);
  
  
  G4MaterialPropertiesTable* Water_MPT = new G4MaterialPropertiesTable();
  G4MaterialPropertiesTable* WaterInterfaceMpt = new G4MaterialPropertiesTable();

  //ref: https://refractiveindex.info/?shelf=main&book=H2O&page=Hale
  std::vector<G4double> rindex_water = {1.3390, 1.3391, 1.3392, 1.3392, 1.3393, 1.3394, 1.3395, 1.3396, 1.3396, 1.3397, 
                                        1.3398, 1.3399, 1.3400, 1.3400, 1.3401, 1.3402, 1.3403, 1.3434, 1.3404, 1.3405, 
                                        1.3406, 1.3407, 1.3408, 1.3408, 1.3409, 1.3410, 1.3411, 1.3412, 1.3412, 1.3413, 
                                        1.3414, 1.3415, 1.3416, 1.3416, 1.3417, 1.3418, 1.3419, 1.3420, 1.3420, 1.3421, 
                                        1.3422, 1.3423, 1.3424, 1.3424, 1.3425, 1.3426, 1.3427, 1.3428, 1.3428, 1.3429, 
                                        1.3430, 1.3431, 1.3432, 1.3434, 1.3435, 1.3436, 1.3437, 1.3438, 1.3440, 1.3441, 
                                        1.3442, 1.3443, 1.3444, 1.3446, 1.3447, 1.3448, 1.3449, 1.3450, 1.3452, 1.3453, 
                                        1.3454, 1.3455, 1.3456, 1.3458, 1.3459, 1.3460, 1.3461, 1.3462, 1.3464, 1.3465, 
                                        1.3466, 1.3467, 1.3468, 1.3470, 1.3471, 1.3472, 1.3473, 1.3474, 1.3476, 1.3477, 
                                        1.3478, 1.3479, 1.3480, 1.3482, 1.3483, 1.3484, 1.3485, 1.3486, 1.3488, 1.3489, 
                                        1.3490, 1.3492, 1.3494, 1.3496, 1.3498, 1.3500, 1.3502, 1.3504, 1.3506, 1.3508, 
                                        1.3510, 1.3512, 1.3514, 1.3516, 1.3518, 1.3520, 1.3522, 1.3524, 1.3526, 1.3528, 
                                        1.3530, 1.3532, 1.3534, 1.3536, 1.3538, 1.3540, 1.3543, 1.3546, 1.3550, 1.3553, 
                                        1.3556, 1.3559, 1.3562, 1.3566, 1.3569, 1.3572, 1.3575, 1.3578, 1.3582, 1.3585, 
                                        1.3588, 1.3591, 1.3594, 1.3598, 1.3601, 1.3604, 1.3607, 1.3610, 1.3614, 1.3617, 
                                        1.3620};
  //ref: https://sci-hub.ru/https://doi.org/10.1039/C5RA11502G
  std::vector<G4double> absorption_water = {169.2437*m, 171.3565*m, 173.3922*m, 175.3392*m, 177.1855*m, 178.9191*m, 180.5284*m, 182.0019*m, 183.3286*m, 184.4981*m, 
                                            185.5008*m, 186.3279*m, 186.9718*m, 187.4259*m, 187.6853*m, 187.7459*m, 187.6056*m, 187.2635*m, 186.7204*m, 185.9783*m, 
                                            185.0412*m, 183.9140*m, 182.6033*m, 181.1166*m, 179.4627*m, 177.6512*m, 175.6927*m, 173.5981*m, 171.3789*m, 169.0471*m, 
                                            166.6146*m, 164.0935*m, 161.4955*m, 158.8324*m, 156.1154*m, 153.3555*m, 150.5630*m, 147.7477*m, 144.9188*m, 142.0850*m, 
                                            139.2541*m, 136.4334*m, 133.6296*m, 130.8485*m, 128.0956*m, 125.3755*m, 122.6924*m, 120.0499*m, 117.4511*m, 114.8986*m, 
                                            112.3945*m, 109.9407*m, 107.5384*m, 105.1887*m, 102.8924*m, 100.6498*m, 98.4612*m, 96.3264*m, 94.2454*m, 92.2177*m, 
                                            90.2426*m, 88.3197*m, 86.4480*m, 84.6266*m, 82.8546*m, 81.1310*m, 79.4546*m, 77.8243*m, 76.2389*m, 74.6973*m, 
                                            73.1983*m, 71.7405*m, 70.3228*m, 68.9440*m, 67.6029*m, 66.2981*m, 65.0286*m, 63.7931*m, 62.5905*m, 61.4196*m, 
                                            60.2794*m, 59.1686*m, 58.0863*m, 57.0314*m, 56.0028*m, 54.9996*m, 54.0207*m, 53.0653*m, 52.1324*m, 51.2211*m, 
                                            50.3305*m, 49.4598*m, 48.6082*m, 47.7749*m, 46.9592*m, 46.1602*m, 45.3773*m, 44.6097*m, 43.8569*m, 43.1182*m, 
                                            42.3929*m, 41.6805*m, 40.9804*m, 40.2920*m, 39.6149*m, 38.9486*m, 38.2924*m, 37.6461*m, 37.0092*m, 36.3812*m, 
                                            35.7618*m, 35.1506*m, 34.5473*m, 33.9515*m, 33.3630*m, 32.7814*m, 32.2065*m, 31.6380*m, 31.0758*m, 30.5195*m, 
                                            29.9691*m, 29.4244*m, 28.8852*m, 28.3514*m, 27.8229*m, 27.2996*m, 26.7814*m, 26.2682*m, 25.7600*m, 25.2567*m, 
                                            24.7584*m, 24.2650*m, 23.7765*m, 23.2930*m, 22.8144*m, 22.3408*m, 21.8723*m, 21.4088*m, 20.9505*m, 20.4973*m, 
                                            20.0495*m, 19.6070*m, 19.1699*m, 18.7383*m, 18.3122*m, 17.8918*m, 17.4771*m, 17.0682*m, 16.6652*m, 16.2682*m, 
                                            15.8771*m};
  //ref: https://refractiveindex.info/?shelf=main&book=H2O&page=Hale
  std::vector<G4double> trasmittance_water = {1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 
                                              1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 
                                              1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 
                                              1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 
                                              1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 
                                              1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 
                                              1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 
                                              1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 
                                              1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 
                                              1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 
                                              1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 
                                              1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 
                                              1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 
                                              1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 
                                              1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 
                                              1.0000}; 
  
  
  Water_MPT->AddProperty("RINDEX", energy, rindex_water);
  Water_MPT->AddProperty("ABSLENGTH", energy, absorption_water);


  WaterInterfaceMpt->AddProperty("TRANSMITTANCE", energy, trasmittance_water);
  WaterInterfaceMpt->AddProperty("RINDEX", energy, rindex_water);
  
  
  water_mat->SetMaterialPropertiesTable(Water_MPT);

  WaterOpticalSurface->SetMaterialPropertiesTable(WaterInterfaceMpt);


 G4OpticalSurface* OilOpticalSurface = new G4OpticalSurface("OilSurface");


    OilOpticalSurface->SetType(dielectric_dielectric);
    OilOpticalSurface->SetModel(unified);
    OilOpticalSurface->SetFinish(groundfrontpainted);


 /*G4LogicalBorderSurface* TeflonOilSurface =*/ new
    G4LogicalBorderSurface("LSB_TeflonOilSurface", physCilindro, physCalotta_Olio_oliva, OilOpticalSurface);
 /*G4LogicalBorderSurface* OilTeflonSurface =*/ new
    G4LogicalBorderSurface("LSB_OilTeflonSurface", physCalotta_Olio_oliva, physCilindro, TeflonOpticalSurface);
 
  /*

  Dato che è impossibile trovare ricerche in letteratura per quanto riguarda i parametri ottici dell'olio, essi sono stati
  ricavati tramite diverse formule. L'indice di rifrazione tramite la formula di Cauchy, ref: 
  https://www.horiba.com/fra/scientific/technologies/spectroscopic-ellipsometry/cauchy-dispersion-module/ mentre i parametri 
  sono stati presi dalla ref https://www.worldscientific.com/doi/10.1142/S1793545821400101 
  La formula della transmittance è stata anch'essa ricavata mediante: 

  */

  std::vector<G4double> rindex_olio_oliva = {1.4114, 1.4115, 1.4116, 1.4118, 1.4119, 1.4120, 1.4121, 1.4122, 1.4124, 1.4125, 
                                             1.4126, 1.4127, 1.4129, 1.4130, 1.4131, 1.4133, 1.4134, 1.4135, 1.4137, 1.4138, 
                                             1.4139, 1.4141, 1.4142, 1.4143, 1.4145, 1.4146, 1.4148, 1.4149, 1.4150, 1.4152, 
                                             1.4153, 1.4155, 1.4156, 1.4158, 1.4159, 1.4161, 1.4162, 1.4164, 1.4165, 1.4167, 
                                             1.4169, 1.4170, 1.4172, 1.4173, 1.4175, 1.4177, 1.4178, 1.4180, 1.4182, 1.4183, 
                                             1.4185, 1.4187, 1.4189, 1.4190, 1.4192, 1.4194, 1.4196, 1.4198, 1.4199, 1.4201, 
                                             1.4203, 1.4205, 1.4207, 1.4209, 1.4211, 1.4213, 1.4215, 1.4217, 1.4219, 1.4221, 
                                             1.4223, 1.4225, 1.4227, 1.4229, 1.4231, 1.4233, 1.4236, 1.4238, 1.4240, 1.4242, 
                                             1.4244, 1.4247, 1.4249, 1.4251, 1.4254, 1.4256, 1.4258, 1.4261, 1.4263, 1.4266, 
                                             1.4268, 1.4270, 1.4273, 1.4276, 1.4278, 1.4281, 1.4283, 1.4286, 1.4289, 1.4291, 
                                             1.4294, 1.4297, 1.4300, 1.4302, 1.4305, 1.4308, 1.4311, 1.4314, 1.4317, 1.4320, 
                                             1.4323, 1.4326, 1.4329, 1.4332, 1.4335, 1.4338, 1.4341, 1.4345, 1.4348, 1.4351, 
                                             1.4355, 1.4358, 1.4361, 1.4365, 1.4368, 1.4372, 1.4375, 1.4379, 1.4382, 1.4386, 
                                             1.4390, 1.4394, 1.4397, 1.4401, 1.4405, 1.4409, 1.4413, 1.4417, 1.4421, 1.4425, 
                                             1.4429, 1.4433, 1.4438, 1.4442, 1.4446, 1.4451, 1.4455, 1.4460, 1.4464, 1.4469, 
                                             1.4473};
  //ref: https://www.scielo.org.mx/scielo.php?pid=S1665-64232020000600333&script=sci_arttext
  std::vector<G4double> absorption_olio_oliva = {0.3561*mm, 0.4272*mm, 0.4717*mm, 0.4613*mm, 0.4735*mm, 0.4831*mm, 0.4902*mm, 0.4970*mm, 0.5045*mm, 0.5136*mm, 
                                                 0.5219*mm, 0.5297*mm, 0.5382*mm, 0.5467*mm, 0.5559*mm, 0.5637*mm, 0.5714*mm, 0.5790*mm, 0.5831*mm, 0.5882*mm, 
                                                 0.5942*mm, 0.5981*mm, 0.6024*mm, 0.6050*mm, 0.6079*mm, 0.6124*mm, 0.6143*mm, 0.6180*mm, 0.6219*mm, 0.6242*mm, 
                                                 0.6289*mm, 0.6321*mm, 0.6341*mm, 0.6361*mm, 0.6386*mm, 0.6435*mm, 0.6460*mm, 0.6456*mm, 0.6485*mm, 0.6494*mm, 
                                                 0.6472*mm, 0.6452*mm, 0.6439*mm, 0.6382*mm, 0.6345*mm, 0.6333*mm, 0.6281*mm, 0.6169*mm, 0.6250*mm, 0.5879*mm, 
                                                 0.5147*mm, 0.5107*mm, 0.5565*mm, 0.5865*mm, 0.5682*mm, 0.5571*mm, 0.5528*mm, 0.5459*mm, 0.5350*mm, 0.5252*mm, 
                                                 0.5139*mm, 0.5040*mm, 0.4965*mm, 0.4880*mm, 0.4773*mm, 0.4619*mm, 0.4468*mm, 0.4367*mm, 0.4243*mm, 0.4092*mm, 
                                                 0.3968*mm, 0.3871*mm, 0.3731*mm, 0.3687*mm, 0.3686*mm, 0.3621*mm, 0.3551*mm, 0.3529*mm, 0.3483*mm, 0.3372*mm, 
                                                 0.3255*mm, 0.3160*mm, 0.3088*mm, 0.3040*mm, 0.3005*mm, 0.2958*mm, 0.2916*mm, 0.2888*mm, 0.2869*mm, 0.2885*mm, 
                                                 0.2890*mm, 0.2846*mm, 0.2774*mm, 0.2714*mm, 0.2639*mm, 0.2570*mm, 0.2534*mm, 0.2503*mm, 0.2541*mm, 0.2427*mm, 
                                                 0.2237*mm, 0.2433*mm, 0.2553*mm, 0.2514*mm, 0.2528*mm, 0.2530*mm, 0.2549*mm, 0.2564*mm, 0.2562*mm, 0.2571*mm, 
                                                 0.2574*mm, 0.2579*mm, 0.2589*mm, 0.2592*mm, 0.2596*mm, 0.2599*mm, 0.2605*mm, 0.2617*mm, 0.2626*mm, 0.2632*mm, 
                                                 0.2636*mm, 0.2639*mm, 0.2640*mm, 0.2641*mm, 0.2647*mm, 0.2650*mm, 0.2646*mm, 0.2648*mm, 0.2650*mm, 0.2650*mm, 
                                                 0.2655*mm, 0.2656*mm, 0.2655*mm, 0.2656*mm, 0.2655*mm, 0.2657*mm, 0.2653*mm, 0.2650*mm, 0.2652*mm, 0.2634*mm, 
                                                 0.2618*mm, 0.2611*mm, 0.2598*mm, 0.2597*mm, 0.2597*mm, 0.2599*mm, 0.2603*mm, 0.2603*mm, 0.2646*mm, 0.2592*mm, 
                                                 0.2467*mm};

  std::vector<G4double> trasmittance_olio_oliva = {0.9106, 0.9106, 0.9106, 0.9105, 0.9105, 0.9104, 0.9104, 0.9104, 0.9103, 0.9103, 
                                                   0.9102, 0.9102, 0.9102, 0.9101, 0.9101, 0.9100, 0.9100, 0.9100, 0.9099, 0.9099, 
                                                   0.9098, 0.9098, 0.9097, 0.9097, 0.9097, 0.9096, 0.9096, 0.9095, 0.9095, 0.9094, 
                                                   0.9094, 0.9093, 0.9093, 0.9092, 0.9092, 0.9091, 0.9091, 0.9090, 0.9090, 0.9089, 
                                                   0.9089, 0.9088, 0.9088, 0.9087, 0.9087, 0.9086, 0.9086, 0.9085, 0.9085, 0.9084, 
                                                   0.9084, 0.9083, 0.9082, 0.9082, 0.9081, 0.9081, 0.9080, 0.9080, 0.9079, 0.9078, 
                                                   0.9078, 0.9077, 0.9077, 0.9076, 0.9075, 0.9075, 0.9074, 0.9073, 0.9073, 0.9072, 
                                                   0.9071, 0.9071, 0.9070, 0.9069, 0.9069, 0.9068, 0.9067, 0.9067, 0.9066, 0.9065, 
                                                   0.9065, 0.9064, 0.9063, 0.9062, 0.9062, 0.9061, 0.9060, 0.9059, 0.9059, 0.9058, 
                                                   0.9057, 0.9056, 0.9055, 0.9055, 0.9054, 0.9053, 0.9052, 0.9051, 0.9050, 0.9049, 
                                                   0.9049, 0.9048, 0.9047, 0.9046, 0.9045, 0.9044, 0.9043, 0.9042, 0.9041, 0.9040, 
                                                   0.9039, 0.9038, 0.9037, 0.9036, 0.9035, 0.9034, 0.9033, 0.9032, 0.9031, 0.9030, 
                                                   0.9029, 0.9028, 0.9027, 0.9026, 0.9025, 0.9024, 0.9022, 0.9021, 0.9020, 0.9019, 
                                                   0.9018, 0.9016, 0.9015, 0.9014, 0.9013, 0.9011, 0.9010, 0.9009, 0.9008, 0.9006, 
                                                   0.9005, 0.9004, 0.9002, 0.9001, 0.8999, 0.8998, 0.8997, 0.8995, 0.8994, 0.8992, 
                                                   0.8991}; 

  
  G4MaterialPropertiesTable* Olio_MPT = new G4MaterialPropertiesTable();
  G4MaterialPropertiesTable* OlioInterfaceMpt = new G4MaterialPropertiesTable();

  
  Olio_MPT->AddProperty("RINDEX", energy, rindex_olio_oliva);
  Olio_MPT->AddProperty("ABSLENGTH", energy, absorption_olio_oliva);


  OlioInterfaceMpt->AddProperty("TRANSMITTANCE", energy, trasmittance_olio_oliva);
  OlioInterfaceMpt->AddProperty("RINDEX", energy, rindex_olio_oliva);


  Olio_Oliva->SetMaterialPropertiesTable(Olio_MPT);


  OilOpticalSurface->SetMaterialPropertiesTable(OlioInterfaceMpt);

/*

Terza ed ultima interfaccia, si ri-usano le già definite G4OPticalSurface per l'acqua ed olio

*/

 /*G4LogicalBorderSurface* OilWaterSurface =*/ new
    G4LogicalBorderSurface("LSB_OilWaterSurface", physCalotta_Olio_oliva, physSferaIntegratrice, WaterOpticalSurface);
 /*G4LogicalBorderSurface* WaterOilSurface =*/ new
    G4LogicalBorderSurface("LSB_WaterOIlSurface", physSferaIntegratrice, physCalotta_Olio_oliva, OilOpticalSurface);

What do you think? Is everything ok?

  • I don’t know where set the attribute polished, which is the right surface?

  • Then, the whole order are correct? I see in the distribution that photon never die in the oil and teflon (vol_ID = 0 detector, 1 oil, 2 water and 3 for teflon) this is wrong and strange:

I suppose that the error(s) is somewhere in one or more G4LogicalSurface, but where? If i put Polished and not groundfrontpainted in the OilOpticalSurface now the photons go through the oil surface:

they enter and are absorbed:

This is correct, I think, but I don’t understand why If I put groundfrontpainted the photons don’t go in the oil (this is wrong):

Thanks for your time and patient, your post are really saving me! I Understanding better how to use GEANT4 :slight_smile:

Looks like progress! Maybe you could put a small air gap between the oil and Teflon. I am kind of out of ideas here though—I think you can probably figure out the rest with some experimentation. :slight_smile:

1 Like

I think the syntax is now correct, but the simulation unfortunately does not give me the expected spectrum, but I would be more inclined to think that the abs. lengh. parameters for water and especially oil are to blame.

Thank you for all your help :slight_smile: .