|
|
[[_TOC_]]
|
|
[[_TOC_]]
|
|
|
|
|
|
|
|
# Customizing wlog file
|
|
# Customizing wlog file
|
|
|
For reporting basic quantities (like particle number, energy, etc) W-SLDA code uses `wlog` file. It is a txt file produced by the function `int logger( )` from [logger.h](https://gitlab.fizyka.pw.edu.pl/wtools/wslda/-/blob/public/st-project-template/logger.h) file. The user can modify this file depending on the specifics of a given problem.
|
|
For reporting basic quantities (such as particle number, energy, etc.), the W-SLDA code uses a `wlog` file. It is a text file produced by the function `int logger( )` from [logger.h](https://gitlab.fizyka.pw.edu.pl/wtools/wslda/-/blob/public/st-project-template/logger.h) file. The user can modify this file depending on the specifics of a given problem.
|
|
|
|
|
|
|
|
## Example
|
|
## Example
|
|
|
Suppose that in addition to defined by default variables, the user needs to print out a new variable:
|
|
Suppose that, in addition to being defined by default, the user needs to print out a new variable:
|
|
|
```math
|
|
```math
|
|
|
\Delta_{\textrm{avg}}(t) = \dfrac{\int |\Delta(\bm{r},t)|(n_a(\bm{r},t)+n_b(\bm{r},t))\,d\bm{r}}{\int (n_a(\bm{r},t)+n_b(\bm{r},t))\,d\bm{r}}
|
|
\Delta_{\textrm{avg}}(t) = \dfrac{\int |\Delta(\bm{r},t)|(n_a(\bm{r},t)+n_b(\bm{r},t))\,d\bm{r}}{\int (n_a(\bm{r},t)+n_b(\bm{r},t))\,d\bm{r}}
|
|
|
```
|
|
```
|
| ... | @@ -13,7 +13,7 @@ In the first step, we define the new variable |
... | @@ -13,7 +13,7 @@ In the first step, we define the new variable |
|
|
int add_custom_variable_to_wdata_metadata(wdata_metadata *wdmd,
|
|
int add_custom_variable_to_wdata_metadata(wdata_metadata *wdmd,
|
|
|
double *params, size_t extra_data_size, void *extra_data)
|
|
double *params, size_t extra_data_size, void *extra_data)
|
|
|
{
|
|
{
|
|
|
// To add a variable use this template
|
|
// To add a variable, use this template
|
|
|
// var_name type unit
|
|
// var_name type unit
|
|
|
wdata_variable var1 = {"E_flow", "real", "none", "wdat"}; // scalar variable
|
|
wdata_variable var1 = {"E_flow", "real", "none", "wdat"}; // scalar variable
|
|
|
wdata_add_variable(wdmd, &var1);
|
|
wdata_add_variable(wdmd, &var1);
|
| ... | @@ -21,7 +21,7 @@ int add_custom_variable_to_wdata_metadata(wdata_metadata *wdmd, |
... | @@ -21,7 +21,7 @@ int add_custom_variable_to_wdata_metadata(wdata_metadata *wdmd, |
|
|
return 0;
|
|
return 0;
|
|
|
}
|
|
}
|
|
|
```
|
|
```
|
|
|
which is (weighted) average value of the delta. This can be done by adding to `logger(..)`:
|
|
which is the (weighted) average value of the delta. This can be done by adding to `logger(..)`:
|
|
|
```c
|
|
```c
|
|
|
int ixyz;
|
|
int ixyz;
|
|
|
int lNXYZ = h_potentials.blocklength;
|
|
int lNXYZ = h_potentials.blocklength;
|
| ... | @@ -30,7 +30,7 @@ for(ixyz=0; ixyz<lNXYZ; ixyz++) delta_avg+=cabs(h_potentials.delta[ixyz])*(h_den |
... | @@ -30,7 +30,7 @@ for(ixyz=0; ixyz<lNXYZ; ixyz++) delta_avg+=cabs(h_potentials.delta[ixyz])*(h_den |
|
|
for(ixyz=0; ixyz<lNXYZ; ixyz++) Ntot+=h_densities.rho_a[ixyz]+h_densities.rho_b[ixyz];
|
|
for(ixyz=0; ixyz<lNXYZ; ixyz++) Ntot+=h_densities.rho_a[ixyz]+h_densities.rho_b[ixyz];
|
|
|
delta_avg /= Ntot;
|
|
delta_avg /= Ntot;
|
|
|
```
|
|
```
|
|
|
and supplementing `printf` statement with appropriate entry, like:
|
|
and supplementing the `printf` statement with an appropriate entry, like:
|
|
|
```c
|
|
```c
|
|
|
// add entry
|
|
// add entry
|
|
|
fprintf(log, "%6d %18.10g %18.10g
|
|
fprintf(log, "%6d %18.10g %18.10g
|
| ... | @@ -67,16 +67,16 @@ and supplementing `printf` statement with appropriate entry, like: |
... | @@ -67,16 +67,16 @@ and supplementing `printf` statement with appropriate entry, like: |
|
|
# Customizing wdata files
|
|
# Customizing wdata files
|
|
|
**Functionality introduced with API_VERSION>=20231218**
|
|
**Functionality introduced with API_VERSION>=20231218**
|
|
|
|
|
|
|
|
The logger allows also to define new variables of results [W-data set](https://gitlab.fizyka.pw.edu.pl/wtools/wdata). It is done in two steps:
|
|
The logger also allows the definition of new variables of results [W-data set](https://gitlab.fizyka.pw.edu.pl/wtools/wdata). It is done in two steps:
|
|
|
1. Adding a definition of a new variable via `add_custom_variable_to_wdata_metadata` function.
|
|
1. Adding a definition of a new variable via the `add_custom_variable_to_wdata_metadata` function.
|
|
|
2. Adding a body of function `write_custom_variable_to_wdata_set` that creates and writes the new variable to wdata set.
|
|
2. Adding a body of function `write_custom_variable_to_wdata_set` that creates and writes the new variable to the wdata set.
|
|
|
|
|
|
|
|
## Example
|
|
## Example
|
|
|
To demonstrate the functionality of extending wdata set by new variables, let us add new variable which is density of the flow energy
|
|
To demonstrate the functionality of extending the wdata set by new variables, let us add a new variable, which is the density of the flow energy
|
|
|
```math
|
|
```math
|
|
|
E_{flow}(\bm{r}) = \frac{\bm{j}_a^2(\bm{r})}{2n_a(\bm{r})} + \frac{\bm{j}_b^2(\bm{r})}{2n_b(\bm{r})}
|
|
E_{flow}(\bm{r}) = \frac{\bm{j}_a^2(\bm{r})}{2n_a(\bm{r})} + \frac{\bm{j}_b^2(\bm{r})}{2n_b(\bm{r})}
|
|
|
```
|
|
```
|
|
|
In the first step, we define the new variable with the name `E_flow`
|
|
In the first step, we define the new variable named `E_flow`
|
|
|
```c
|
|
```c
|
|
|
int add_custom_variable_to_wdata_metadata(wdata_metadata *wdmd,
|
|
int add_custom_variable_to_wdata_metadata(wdata_metadata *wdmd,
|
|
|
double *params, size_t extra_data_size, void *extra_data)
|
|
double *params, size_t extra_data_size, void *extra_data)
|
| ... | @@ -118,7 +118,7 @@ int write_custom_variable_to_wdata_set(wdata_metadata *wdmd, |
... | @@ -118,7 +118,7 @@ int write_custom_variable_to_wdata_set(wdata_metadata *wdmd, |
|
|
ixyz++; // go to the next point, it should be the last line of the triple loop
|
|
ixyz++; // go to the next point, it should be the last line of the triple loop
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// to add variable to binary file use this function
|
|
// to add a variable to a binary file, use this function
|
|
|
wdata_write_cycle(wdmd, "E_flow", E_flow);
|
|
wdata_write_cycle(wdmd, "E_flow", E_flow);
|
|
|
|
|
|
|
|
free(E_flow); // clear memory
|
|
free(E_flow); // clear memory
|
| ... | | ... | |