funkalicious 0.1

dotcode_wavefunction.c File Reference

#include <stdlib.h>
#include <libdotcode/dotcode_wavefunction.h>
Include dependency graph for dotcode_wavefunction.c:

Go to the source code of this file.

Functions

hotfunc ___const
___always_inline long unsigned
int 
get_wavefunction_storage_index (unsigned int x, unsigned int y, unsigned int z, unsigned int im, unsigned int b, unsigned int Nx, unsigned int Ny, int Nb)
___const long unsigned int get_wavefunction_storage_index_ (unsigned int x, unsigned y, unsigned z, unsigned im, unsigned b, unsigned Nx, unsigned Ny, unsigned Nb)
hotfunc ___always_inline double * get_wavefunction_storage (unsigned int x, unsigned int y, unsigned int z, unsigned int im, unsigned int b, struct wavefunction *wf)
double * get_wavefunction_storage_ (unsigned int x, unsigned int y, unsigned int z, unsigned int im, unsigned int b, struct wavefunction *wf)
hotfunc ___always_inline const
double * 
get_wavefunction_storage_c (unsigned int x, unsigned int y, unsigned int z, unsigned int im, unsigned int b, const struct wavefunction *wf)
const double * get_wavefunction_storage_c_ (unsigned int x, unsigned int y, unsigned int z, unsigned int im, unsigned int b, const struct wavefunction *wf)
struct densitydotcode_wavefunction_get_density_in_band (const struct wavefunction *wf, int band)
void dotcode_wavefunction_free (struct wavefunction *wf)
void dotcode_wavefunction_free_resources (struct wavefunction *wf)

Function Documentation

void dotcode_wavefunction_free ( struct wavefunction wf)

Provides basic routines for getting and using a dotcode wavefunction.

Copyright (C) 2011 Joseph Pingenot

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.frees a wavefunction and its resources

Parameters:
wfwavefunction to free

Definition at line 82 of file dotcode_wavefunction.c.

References dotcode_wavefunction_free_resources().

Here is the call graph for this function:

void dotcode_wavefunction_free_resources ( struct wavefunction wf)

Only frees the resources within the wavefunction struct, not the wavefunction struct itself.

Parameters:
wfwavefunction to free

Definition at line 87 of file dotcode_wavefunction.c.

References wavefunction::file, and wavefunction::storage.

Referenced by dotcode_wavefunction_free(), and main().

                                                                  {
  g_object_unref(wf->file);
  free(wf->storage);
}

Here is the caller graph for this function:

struct density* dotcode_wavefunction_get_density_in_band ( const struct wavefunction wf,
int  band 
) [read]

Gets the probability density within the specified band

Parameters:
wfthe wavefunction to get the density out of
bandband to use
Returns:
struct density with the probability density across the distribution
Note:
that the density retains the LAPACK-like implicit multiplication by dx^3.

Definition at line 62 of file dotcode_wavefunction.c.

References wavefunction::bands, wavefunction::dx, get_density_storage_at_(), get_wavefunction_storage_c(), wavefunction::N, and new_density().

Referenced by dotcode_wavefunction_get_percentage_in_band(), and main().

                                                                                                  { 
  if(band >= wf->bands) return NULL;
  unsigned x, y, z;
  double re, im;
  struct density* d = new_density(wf->N, wf->dx, 0.0);
  #ifdef OPENMP
  #pragma omp parallel for private(x, y, z, re, im)
  #endif
  for(z=0; z<wf->N[2]; ++z) {
    for(y=0; y<wf->N[1]; ++y) {
      for(x=0; x<wf->N[0]; ++x) {
  re = *get_wavefunction_storage_c(x, y, z, 0, band, wf);
  im = *get_wavefunction_storage_c(x, y, z, 1, band, wf);
  *get_density_storage_at_(x, y, z, d) = re*re + im*im;
      }
    }
  }
  return d;
}

Here is the call graph for this function:

Here is the caller graph for this function:

hotfunc ___always_inline double* get_wavefunction_storage ( unsigned int  x,
unsigned int  y,
unsigned int  z,
unsigned int  im,
unsigned int  b,
struct wavefunction wf 
)

Definition at line 48 of file dotcode_wavefunction.c.

References wavefunction::bands, get_wavefunction_storage_index(), wavefunction::N, and wavefunction::storage.

Referenced by get_wavefunction_storage_().

                                                                                                                                                                    {
  return &(wf->storage[get_wavefunction_storage_index(x, y, z, im, b, wf->N[0], wf->N[1], wf->bands)]);
}

Here is the call graph for this function:

Here is the caller graph for this function:

double* get_wavefunction_storage_ ( unsigned int  x,
unsigned int  y,
unsigned int  z,
unsigned int  im,
unsigned int  b,
struct wavefunction wf 
)

Gets the storage address for a specified index; just de-reference to get or set the value

Note:
args are the same as get_wavefunction_storage_index_
Returns:
pointer to the double at the specified location.

Definition at line 51 of file dotcode_wavefunction.c.

References get_wavefunction_storage().

                                                                                                                                            {
  return get_wavefunction_storage(x, y, z, im, b, wf);
}

Here is the call graph for this function:

hotfunc ___always_inline const double* get_wavefunction_storage_c ( unsigned int  x,
unsigned int  y,
unsigned int  z,
unsigned int  im,
unsigned int  b,
const struct wavefunction wf 
)

Definition at line 55 of file dotcode_wavefunction.c.

References wavefunction::bands, get_wavefunction_storage_index(), wavefunction::N, and wavefunction::storage.

Referenced by dotcode_wavefunction_get_density_in_band(), and get_wavefunction_storage_c_().

                                                                                                                                                                                  {
  return &(wf->storage[get_wavefunction_storage_index(x, y, z, im, b, wf->N[0], wf->N[1], wf->bands)]);
}

Here is the call graph for this function:

Here is the caller graph for this function:

const double* get_wavefunction_storage_c_ ( unsigned int  x,
unsigned int  y,
unsigned int  z,
unsigned int  im,
unsigned int  b,
const struct wavefunction wf 
)

Gets the storage address for a specified index (but const); just de-reference to get the value

Note:
args are the same as get_wavefunction_storage_index_
Returns:
pointer (const) to the double at the specified location.

Definition at line 58 of file dotcode_wavefunction.c.

References get_wavefunction_storage_c().

Referenced by dotcode_wavefunction_integrate_sum(), and dotcode_wavefunction_integrate_sum_parallel().

                                                                                                                                                          {
  return get_wavefunction_storage_c(x, y, z, im, b, wf);
}

Here is the call graph for this function:

Here is the caller graph for this function:

hotfunc ___const ___always_inline long unsigned int get_wavefunction_storage_index ( unsigned int  x,
unsigned int  y,
unsigned int  z,
unsigned int  im,
unsigned int  b,
unsigned int  Nx,
unsigned int  Ny,
int  Nb 
)

Provides basic routines for getting and using a dotcode wavefunction.

Copyright (C) 2011 Joseph Pingenot

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. Gets the index into the storage member for a wavefunction, or for a density

Parameters:
xx index component
yy index component
zz index component
bband index component
im1 if imaginary component is wanted; 0 else.
NxNumber of x sites
NyNumber of y sites
NbNumber of bands
Returns:
long unsigned int, which is the address in the storage array.
Note:
there is no error checking, for speed purposes. E.g. if im is 3, it'll just be blindly used as a 3 and you'll be addressing the imaginary component of the next index.
Nz is not needed.

Definition at line 41 of file dotcode_wavefunction.c.

Referenced by get_wavefunction_storage(), get_wavefunction_storage_c(), get_wavefunction_storage_index_(), and internal_add_to_density().

                                                                                                                                                                                                              {
  return im + 2*(b + Nb*(x + Nx*(y + Ny*(z))));
}

Here is the caller graph for this function:

___const long unsigned int get_wavefunction_storage_index_ ( unsigned int  x,
unsigned  y,
unsigned  z,
unsigned  im,
unsigned  b,
unsigned  Nx,
unsigned  Ny,
unsigned  Nb 
)

Gets the index into the storage member for a wavefunction, or for a density

Parameters:
xx index component
yy index component
zz index component
bband index component
im1 if imaginary component is wanted; 0 else.
NxNumber of x sites
NyNumber of y sites
NbNumber of bands
Returns:
long unsigned int, which is the address in the storage array.
Note:
there is no error checking, for speed purposes. E.g. if im is 3, it'll just be blindly used as a 3 and you'll be addressing the imaginary component of the next index.
Nz is not needed.

Definition at line 44 of file dotcode_wavefunction.c.

References get_wavefunction_storage_index().

                                                                                                                                                                   {
  return get_wavefunction_storage_index(x, y, z, im, b, Nx, Ny, Nb);
}

Here is the call graph for this function:

 All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines