Page 1 of 1

Explanation about DIAG_DXXXX

Posted: Mon 6 Dec 2021 07:18
by Bruce Yee
Dear Didier,

The DIAG_DSIZE2 (similar to DIAG_DSIZE3 and DIAG_DPSIZE2) associates delta size in X and Y at two different points of the lattice.
Could you explain me or sent the script of how it is done?
I want to use something similar to associate some beam properties at different point in the lattice.

Thanks for the help,

Bruce

Re: Explanation about DIAG_DXXXX

Posted: Mon 6 Dec 2021 15:16
by Didier
Dear Bruce,

So, I'm not sure to understand your question but one thing is sure, DIAG_DSIZE2, DIAG_DSIZE3 & , DIAG_DPSIZE2 suppose that you have put in your file at least 2 diags of the same type in order to have values for diag(n) & diag(n-1). if 3 diag are present the crietria will be like following:

Vcr= (diag(n-2)-diag(n-1))^2 + (diag(n-1)-diag(n))^2

This is not the case for DIAG_DSIZE which needs only one diag

Regards,

Didier

Re: Explanation about DIAG_DXXXX

Posted: Tue 7 Dec 2021 05:34
by Bruce Yee
Dear Didier,

Thanks for your reply, and sorry to be ambiguous with my question.
As you kindly explain in your answer, if you have the same type of element in 3 positions, you can relate by the following criteria.

Vcr= (diag(n-2)-diag(n-1))^2 + (diag(n-1)-diag(n))^2.

How do you access the nth diag values? i.e., Is there a variable "n" associated to the number of times that diagnostic appears?

I have on mind to make a loop over the n diagnostics, something like

diagt=0

for (in i=0,i<n-1;i++):
diagt=diagt + (diag[i+1] - diag)^2.

*diag_value=diagt


So far, with the example script, I have access only to the point that I put the diagnostic.
For example, I can measure the x rms by computing "*diag_value=sqrt(Bmat[0][0]) ", with Bmat[0][0] is associated to the diagnostic position.

If I have n same diagnostic at different positions, Is the value of the kth diagnostic like this diag_value[k]=sqrt(Bmat[0][0])[k] ???

I hope to make myself more understandable.

Thanks for your help,

Bruce

Re: Explanation about DIAG_DXXXX

Posted: Tue 7 Dec 2021 08:38
by Didier
Dear Bruce,

In fact, in your code you only have data for the current diagnotic. So you have several solutions I think. Either you keep the data of the previous diags in a file, or you use the already available files such as ENV_Diag.dat and PAR_Diag.dat, or you use 'static' variables allowing to keep in memory the previous states. Personally I use this last method allowing me to keep in memeory the diag n-1 values.

Regards,

Didier

Re: Explanation about DIAG_DXXXX

Posted: Wed 8 Dec 2021 09:29
by Bruce Yee
Dear Didier,

Thank you very much for your advices.

Could be possible to have access to the "static" variable script that you used to keep in memory the diagnostic values?

Thanks for your help,

Bruce

Re: Explanation about DIAG_DXXXX

Posted: Wed 8 Dec 2021 10:06
by Didier
Dear Bruce,

In my mind "static" it's just a way of programming in C that allows to keep variables alive, even when exiting the function

https://www.studytonight.com/cpp/static-keyword.php

Regards,

Didier

Re: Explanation about DIAG_DXXXX

Posted: Thu 9 Dec 2021 08:09
by Bruce Yee
Dear Didier,

Thanks for the reference. I will be working on it.

Best regards,

Bruce