funkalicious 0.1

dc_get_composition.c File Reference

#include <stdio.h>
#include <glib-2.0/glib.h>
#include <gio/gio.h>
#include <libpostproc/lp_wavefunction.h>
#include <libdotcode/dotcode_wavefunction.h>
#include <libdotcode/wavefunction_simple_operations.h>
#include <libdotcode/dotcode_data.h>
#include <libpostproc/unit_conversion.h>
Include dependency graph for dc_get_composition.c:

Go to the source code of this file.

Functions

int main (int argc, char **argv)

Function Documentation

int main ( int  argc,
char **  argv 
)

Gets the composition of 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/>.

Definition at line 30 of file dc_get_composition.c.

References wavefunction::bands, dotcode_band_short_names, dotcode_wavefunction_free_resources(), dotcode_wavefunction_get_percentage_in_band(), dotcode_wavefunction_integrate_sum(), dotcode_wavefunction_integrate_sum_parallel(), e, wavefunction::file, and load_wavefunctions().

                                {
  g_type_init();
  printf("#file\t%s", dotcode_band_short_names[0]);
  for(int band=1; band<8; band++) {
    printf("\t%s", dotcode_band_short_names[band]);
  }
  printf("\tSUM\tSTSUM re\tSTSUM im\tMTSUM re\tMTSUM im\n");
  for(int wfn=1; wfn<argc; ++wfn) {
    GList* l=NULL;
    GFile* f = g_file_new_for_commandline_arg(argv[wfn]);
    struct wavefunction wf = {.file=f, .charge=1, .N={0, 0, 0}, .dx={0, 0, 0}, .bands=0, .storage=NULL};
    l = g_list_append(l, &wf);
    GError *e = NULL;
    load_wavefunctions(l, &e);
    if(e == NULL) {
      double band_pcts[wf.bands];
      printf("%s", argv[wfn]);
      for(int band=0; band<wf.bands; band++) {
  band_pcts[band] = dotcode_wavefunction_get_percentage_in_band(&wf, band);
  printf("\t%g", band_pcts[band]);
      }
      double sum = band_pcts[0];
      for(int i=1; i<wf.bands; ++i) sum += band_pcts[i];
      printf("\t%g", sum);
      double im;
      dotcode_wavefunction_integrate_sum(&wf, NULL, &wf, &sum, &im, NULL);
      printf("\t%g\t%g", sum, im);
      dotcode_wavefunction_integrate_sum_parallel(&wf, NULL, &wf, &sum, &im, NULL);
      printf("\t%g\t%g\n", sum, im);
      dotcode_wavefunction_free_resources(&wf);
    }else{
      fprintf(stderr, "ERROR loading wavefunction (%s): %s", argv[wfn], e->message);
    }
    g_list_free(l);
    if(e != NULL) g_error_free(e);
  }
  return 0;
}

Here is the call graph for this function:

 All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines