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
  • User defined parameters

User defined parameters · Changes

Page history
Update User defined parameters authored Feb 19, 2026 by Gabriel Wlazłowski's avatar Gabriel Wlazłowski
Hide whitespace changes
Inline Side-by-side
User-defined-parameters.md
View page @ 44e8d275
[[_TOC_]]
# Custom parameters # Custom parameters
The W-SLDA toolkit provides a framework for creating flexible parametrization of formulas. The list of numbers (of double type) that can be passed from an input file to the code is called *custom parameters*. In the input file they start with the tag: The W-SLDA toolkit provides a framework for creating flexible parametrization of formulas. The list of numbers (of double type) that can be passed from an input file to the code is called *custom parameters*. In the input file, they start with the tag:
```bash ```bash
# Custom parameters # Custom parameters
params0 0.0 # value of the params[0], simple syntax params0 0.0 # value of the params[0], simple syntax
...@@ -14,10 +16,10 @@ strings[2] = "ccc"; # (global) variable strings[2], C style ...@@ -14,10 +16,10 @@ strings[2] = "ccc"; # (global) variable strings[2], C style
``` ```
The maximal number of parameters is specified in `predefines.h` by macro-variable: The maximal number of parameters is specified in `predefines.h` by macro-variable:
```c ```c
// Maximal number of parameters in params array // Maximal number of parameters in the params array
#define MAX_USER_PARAMS 32 #define MAX_USER_PARAMS 32
``` ```
When the program reads the input file, custom parameters are uploaded into `params` array in a such way that *paramsk* is assigned to `params[k]`. The pointer to the array is passed to each user-defined function, for example: When the program reads the input file, custom parameters are uploaded into the `params` array. The pointer to the array is passed to each user-defined function, for example:
```c ```c
double v_ext(int ix, int iy, int iz, int it, int spin, double *params, size_t extra_data_size, void *extra_data) double v_ext(int ix, int iy, int iz, int it, int spin, double *params, size_t extra_data_size, void *extra_data)
{ {
...@@ -28,30 +30,35 @@ double v_ext(int ix, int iy, int iz, int it, int spin, double *params, size_t ex ...@@ -28,30 +30,35 @@ double v_ext(int ix, int iy, int iz, int it, int spin, double *params, size_t ex
} }
``` ```
During the self-iteration process, before `params` array is passed to user-defined functions the array can be processed by the function: During the self-iteration process, before the `params` array is passed to user-defined functions, the array can be processed by the function:
```c ```c
/** /**
* THIS FUNCTION IS CALLED DURING THE SELF-CONSISTENT PROCESS. * THIS FUNCTION IS CALLED DURING THE SELF-CONSISTENT PROCESS.
* After loading params array from input file, the parameters are processed by this routine. * After loading the params array from the input file, the parameters are processed by this routine.
* The routine is executed at the beginning of each iteration. * The routine is executed at the beginning of each iteration.
* @param params array of size MAX_USER_PARAMS with parameters from input file. * @param params array of size MAX_USER_PARAMS with parameters from input file.
* @param kF typical Fermi momentum scale of the problem. * @param kF typical Fermi momentum scale of the problem.
* kF=referencekF if the referencekF tag is indicated in the input file, * kF=referencekF if the referencekF tag is indicated in the input file,
* otherwise to kF value is assigned according to formula kF=(3*pi^2*n)^{1/3}, where n corresponds to maximal density. * kF=referencekF(...) otherwise.
* You can also set kF at request in this function using (*kF)=myvalue; * You can also set kF at request in this function using (*kF)=myvalue;
* @param mu array with chemical potentials: mu[SPINA] and mu[SPINB]. * @param mu array with chemical potentials: mu[SPINA] and mu[SPINB].
* @param extra_data_size size of extra_data in bytes, if extra_data size=0 the optional data is not uploaded * @param extra_data_size size of extra_data in bytes, if extra_data size=0 the optional data is not uploaded
* @param extra_data optional set of data uploaded by load_extra_data() * @param extra_data optional set of data uploaded by load_extra_data()
* For more info, see: Wiki-> User-defined parameters
* */ * */
void process_params(double *params, double *kF, double *mu, size_t extra_data_size, void *extra_data) void process_params(double *params, double *kF, double *mu, size_t extra_data_size, void *extra_data)
{ {
// PROCESS INPUT FILE PARAMETERS // if akF is active, then overwrite the value of input->sclgth
// value of kF is generated by the function referencekF(...)
if(input->akF!=0.0) input->sclgth = input->akF/kF[0];
// PROCESS INPUT FILE PARAMETERS
// ... add here your code ...
} }
``` ```
Usage of `process_params( )` allows for parametrization of user-defined functions in terms of dimensionless values, which are typically more intuitive. For example: Using `process_params( )` allows parametrization of user-defined functions in terms of dimensionless values, which are typically more intuitive. For example:
```bash ```bash
params2 2.0 # barrier height, in units of chemical potential mu_a params[2] = 2.0 # barrier height, in units of chemical potential mu_a
``` ```
and `process_params( )` converts *params2* into dimensional quantity and `process_params( )` converts *params2* into dimensional quantity
```c ```c
...@@ -62,7 +69,7 @@ void process_params(double *params, double *kF, double *mu, size_t extra_data_si ...@@ -62,7 +69,7 @@ void process_params(double *params, double *kF, double *mu, size_t extra_data_si
``` ```
# Passing external data to user-defined functions # Passing external data to user-defined functions
To each user-defined function, arbitrary external data can be passed called *extra data*. The extra data is uploading before the self-consistent starts. In order to activate this option user must provide content of functions: To each user-defined function, arbitrary external data can be passed, called *extra data*. The extra data is being uploaded before calculations start. In order to activate this option user must provide the content of the functions:
```c ```c
/** /**
* This function provides size of extra_data array, in bytes. * This function provides size of extra_data array, in bytes.
...@@ -80,13 +87,13 @@ size_t get_extra_data_size(double *params) ...@@ -80,13 +87,13 @@ size_t get_extra_data_size(double *params)
and and
```c ```c
/** /**
* This function loads data into extra_data array. * This function loads data into the extra_data array.
* This function is thread-safe. * This function is thread-safe.
* @param size size of array computed using function get_extra_data_size() * @param size size of array computed using function get_extra_data_size()
* @param extra_data pointer to array that should be filled with data * @param extra_data pointer to an array that should be filled with data
* @param params with input file parameters. * @param params with input file parameters.
* NOTE: the array contains bare input file values, not processed by process_params()! * NOTE: the array contains bare input file values, not processed by process_params()!
* @return 0 if load is successful, otherwise return error code. If nonzero value is returned the main code will terminate. * @return 0 if load is successful, otherwise return error code. If a nonzero value is returned, the main code will terminate.
* */ * */
int load_extra_data(size_t size, void *extra_data, double *params) int load_extra_data(size_t size, void *extra_data, double *params)
{ {
...@@ -98,7 +105,7 @@ int load_extra_data(size_t size, void *extra_data, double *params) ...@@ -98,7 +105,7 @@ int load_extra_data(size_t size, void *extra_data, double *params)
``` ```
# Predefined variables # Predefined variables
Each variable defined in `predefines.h` is accessible over entire file `problem-definition.h`. User can defined new variable in `predefines.h`, like Each variable defined in `predefines.h` is accessible over the entire file `problem-definition.h`. The user can define a new variable in `predefines.h`, like
```c ```c
#define MYVALUE 10.0; #define MYVALUE 10.0;
``` ```
......
Clone repository

Content of Documentation
Official webpage
W-BSK Toolkit