Skip to content

GitLab

  • Menu
Projects Groups Snippets
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • wslda wslda
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 0
    • Issues 0
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Packages & Registries
    • Packages & Registries
    • Package Registry
    • Container Registry
    • Infrastructure Registry
  • Analytics
    • Analytics
    • CI/CD
    • Repository
    • Value stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • wtools
  • wsldawslda
  • Wiki
  • Logger

Logger · Changes

Page history
Update Logger authored Feb 20, 2026 by Gabriel Wlazłowski's avatar Gabriel Wlazłowski
Show whitespace changes
Inline Side-by-side
Logger.md
View page @ 678cf5f7
[[_TOC_]]
# 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
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
\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
int add_custom_variable_to_wdata_metadata(wdata_metadata *wdmd,
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
wdata_variable var1 = {"E_flow", "real", "none", "wdat"}; // scalar variable
wdata_add_variable(wdmd, &var1);
......@@ -21,7 +21,7 @@ int add_custom_variable_to_wdata_metadata(wdata_metadata *wdmd,
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
int ixyz;
int lNXYZ = h_potentials.blocklength;
......@@ -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];
delta_avg /= Ntot;
```
and supplementing `printf` statement with appropriate entry, like:
and supplementing the `printf` statement with an appropriate entry, like:
```c
// add entry
fprintf(log, "%6d %18.10g %18.10g
......@@ -67,16 +67,16 @@ and supplementing `printf` statement with appropriate entry, like:
# Customizing wdata files
**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:
1. Adding a definition of a new variable via `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.
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 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 the wdata set.
## 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
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
int add_custom_variable_to_wdata_metadata(wdata_metadata *wdmd,
double *params, size_t extra_data_size, void *extra_data)
......@@ -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
}
// 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);
free(E_flow); // clear memory
......
Clone repository

Content of Documentation
Official webpage
W-BSK Toolkit