Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Laue case in SRW sroptcryst.h file #118

Open
ia-petrov opened this issue Jan 25, 2018 · 5 comments
Open

Laue case in SRW sroptcryst.h file #118

ia-petrov opened this issue Jan 25, 2018 · 5 comments

Comments

@ia-petrov
Copy link
Collaborator

ia-petrov commented Jan 25, 2018

We have been looking to the file to try to include the Laue geometry in the sroptcryst.h and we think that the definition of the variable bee is not general. The bee variable definition only agrees with Zachariasen in the case of symmetric Bragg. In order to be used both in Laue and Bragg case, it's sensible to define bee as gamma_0/gamma_h.

We also think that it will be interesting to define how the asymmetry parameter is define in python script. tbc

@ia-petrov
Copy link
Collaborator Author

Definition of bee as 1/(1+(n*h)/(n*k0)) since 1+(n*h)/(n*k0)=(n*kh)/(n*k0) is the same as gamma_0/gamma_h, and it should be correct for any geometry and assymmetry. Now the question is if during calculation of diffracted wavefront in Laue case it will be possible to use such definition.

@Angelrf86
Copy link

In the case that the definition of bee would be 1/(1+(nh)/(nk0)) is needed to define the asymmetry variable for a symmetric Laue case as pi/2 and not 0. It should work and I think I have an old version from 2016 that was able to reproduce Laue in this way.

@Angelrf86
Copy link

The more important part of this issue it is not the definition of bee, but the inclusion of the Zachariasen equations for Laue geometry that are still not in sroptcryst.h.

@bnash
Copy link

bnash commented Jul 9, 2018

@Angelrf86, I didn't find sroptcryst.h in the WPG repository. Here it is in O Chubar's SRW repository:
https://github.com/ochubar/SRW/blob/087ce511950156b7f499539eb45e36595c425b06/cpp/src/core/sroptcryst.h

@Angelrf86
Copy link

Angelrf86 commented Jul 9, 2018

At the moment the sroptcryst.h is only defined for Bragg:

char m_uc; // crystal use case: 1- Bragg Reflection, 2- Bragg Transmission (Laue cases to be added)

We could add the Laue cases as 3.- Laue Reflection and 4.- Laue Transmission.

In line 133 should be changed the range m_uc from m_uc > 2 to m_uc > 4

if((m_uc < 1) || (m_uc > 4)) throw IMPROPER_OPTICAL_COMPONENT_MIRROR_USE_CASE;

In line 138 should be changed that also m_uc == 4 is a transmitted case.

if((m_uc == 2) || (m_uc == 4)) m_itrans = 1;

I would add a variable that defines if is Laue or Bragg Geometry, which depends of m_uc:

char LorB
LorB = 0;
if (m_uc == 3)  || (m_uc == 4)) LorB = 1;

Below in line 894 of the code is needed to introduce the Laue case equations:

// Calculate the complex reflectivity DHsgC for sigma polarization: 
complex<double> queC = bee*m_psihc*m_psimhc;
complex<double> sqrqzC = sqrt(queC + zeeC*zeeC);
complex<double> del1C = 0.5*(m_psi0c - zeeC + sqrqzC);
complex<double> del2C = 0.5*(m_psi0c - zeeC - sqrqzC);
complex<double> x1C = (-zeeC + sqrqzC) / m_psimhc;
complex<double> x2C = (-zeeC - sqrqzC) / m_psimhc;
//complex<double> ph1C = 2.*pi*iC*k0Ai*del1C*(m_thicum*1.E+04)/gamma0;
//complex<double> ph2C = 2.*pi*iC*k0Ai*del2C*(m_thicum*1.E+04)/gamma0;
complex<double> aux_phC = 2.*pi*iC*k0Ai*(m_thicum*1.E+04) / gamma0;
complex<double> ph1C = aux_phC*del1C;
complex<double> ph2C = aux_phC*del2C;

complex<double> DHsgC, Cph1C, Cph2C, D0trsC;

//Laue or Bragg if
if LorB == 0
{
        if(real(ph1C) > logDBMax) DHsgC = x2C;
	else if(real(ph2C) > logDBMax) DHsgC = x1C;
	else
	{
		Cph1C = exp(ph1C);
		Cph2C = exp(ph2C);
		DHsgC = x1C*x2C*(Cph2C - Cph1C)/(Cph2C*x2C - Cph1C*x1C);
	}


	if(m_itrans == 1)
	{
		// calculate the complex reflectivity D0trsC of the transmitted beam. 
		if(real(ph1C) > logDBMax)
		{
			Cph2C = exp(ph2C);
			D0trsC = -Cph2C*(x2C - x1C)/x1C;
		}
		else if(real(ph2C) > logDBMax)
		{
			Cph1C = exp(ph1C);
			D0trsC = +Cph1C*(x2C - x1C)/x2C;
		}
		else D0trsC = Cph1C*Cph2C*(x2C - x1C)/(Cph2C*x2C - Cph1C*x1C);
	}
}
else if(LorB == 1)
{
        D0trsC = x2C * x1C*(Cph2C-Cph1C)/(x2C - x1C);
	
        if(m_itrans == 1)
	{
               D0trsC = (x2C *Cph1C-x1C*Cph2C )/(x2C - x1C); 
         // _To check is if this definition as written in Zachariasen is correct for this core, it seems that in the definition of H there is a (-) signe that may need to be enter for making D0trsC = (x1C*Cph2C -x2C *Cph1C)/(x2C - x1C);_
	}
}


//_Also for PI case_ 

// Calculate the complex reflectivity DHpiC for pi polarization: 
//cos2t = cos(2.*thBrd); //OC: moved to members m_cos2t
queC = bee*m_psihc*m_psimhc*m_cos2t*m_cos2t;
sqrqzC = sqrt(queC + zeeC*zeeC);
del1C = 0.5*(m_psi0c - zeeC + sqrqzC);
del2C = 0.5*(m_psi0c - zeeC - sqrqzC);
x1C = (-zeeC + sqrqzC) / (m_psimhc*m_cos2t);
x2C = (-zeeC - sqrqzC) / (m_psimhc*m_cos2t);
ph1C = 2.*pi*iC*k0Ai*del1C*(m_thicum*1.E+04) / gamma0;
ph2C = 2.*pi*iC*k0Ai*del2C*(m_thicum*1.E+04) / gamma0;

complex<double> DHpiC, D0trpC;

 //Laue or Bragg if
 if LorB == 0
 {
       if(real(ph1C) > logDBMax) DHpiC = x2C;
       else if(real(ph2C) > logDBMax) DHpiC = x1C;
       else
       {
	        Cph1C = exp(ph1C);
        	Cph2C = exp(ph2C);
	        DHpiC = x1C*x2C*(Cph2C - Cph1C)/(Cph2C*x2C - Cph1C*x1C);
        }

	if(m_itrans == 1)
	{
		// calculate the complex reflectivity D0trpC of the transmitted beam. 
		if (real(ph1C) > logDBMax)
		{
			Cph2C = exp(ph2C);
			D0trpC = -Cph2C*(x2C - x1C)/x1C;
		}
		else if (real(ph2C) > logDBMax)
		{
			Cph1C = exp(ph1C);
			D0trpC = +Cph1C*(x2C - x1C)/x2C;
		}
		else D0trpC = Cph1C*Cph2C*(x2C - x1C)/(Cph2C*x2C - Cph1C*x1C);
	}
 }
else if(LorB == 1)
{
        D0trsC = x2C * x1C*(Cph2C-Cph1C)/(x2C - x1C);
	
        if(m_itrans == 1)
	{
               D0trsC = (x2C *Cph1C-x1C*Cph2C )/(x2C - x1C); 
               // _To check is if this definition as written in Zachariasen is correct for this core, it seems that in the definition of H there is a (-) signe that may need to be enter for making D0trsC = (x1C*Cph2C -x2C *Cph1C)/(x2C - x1C);_
	}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants