Ignore:
Timestamp:
Sep 24, 2013 4:40:58 PM (11 years ago)
Author:
gah
Message:

sync with trunk

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/blt4/examples/objects/app-fermi/c/ex3/fermi.c

    r1824 r3957  
    1 // ----------------------------------------------------------------------
    2 //  EXAMPLE: Fermi-Dirac function in C
    3 //
    4 //  This simple example shows how to use Rappture within a simulator
    5 //  written in C.
    6 // ======================================================================
    7 //  AUTHOR:  Derrick Kearney, Purdue University
    8 //  Copyright (c) 2005-2009  Purdue Research Foundation
    9 //
    10 //  See the file "license.terms" for information on usage and
    11 //  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
    12 // ======================================================================
    13 
     1/*
     2 * ----------------------------------------------------------------------
     3 *  EXAMPLE: Fermi-Dirac function in C
     4 *
     5 *  This simple example shows how to use Rappture within a simulator
     6 *  written in C.
     7 * ======================================================================
     8 *  AUTHOR:  Derrick Kearney, Purdue University
     9 *  Copyright (c) 2004-2012  HUBzero Foundation, LLC
     10 *
     11 *  See the file "license.terms" for information on usage and
     12 *  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
     13 * ======================================================================
     14 */
    1415#include "rappture.h"
    1516
     
    2324int main(int argc, char * argv[]) {
    2425
    25     // declare variables to interact with Rappture
     26    /* declare variables to interact with Rappture */
    2627    double T          = 0.0;
    2728    double Ef         = 0.0;
     
    3233
    3334
    34     // declare program variables
     35    /* declare program variables */
    3536    double E          = 0.0;
    3637    double dE         = 0.0;
     
    4546    double fArr2[nPts];
    4647
    47     // initialize the global interface
     48    /* initialize the global interface */
    4849    Rp_InterfaceInit(argc,argv,&fermi_io);
    4950
    50     // check the global interface for errors
     51    /* check the global interface for errors */
    5152    if (Rp_InterfaceError() != 0) {
    52         // there were errors while setting up the interface
    53         // dump the traceback
     53        /* there were errors while setting up the interface */
     54        /* dump the traceback */
    5455        Rp_Outcome *o = Rp_InterfaceOutcome();
    5556        fprintf(stderr, "%s", Rp_OutcomeContext(o));
     
    5859    }
    5960
    60     // connect variables to the interface
    61     // look in the global interface for an object named
    62     // "temperature", convert its value to Kelvin, and
    63     // store the value into the address of T.
    64     // look in the global interface for an object named
    65     // "Ef", convert its value to electron Volts and store
    66     // the value into the address of Ef.
    67     // look in the global interface for the columns to
    68     // store data. retrieve them for later use.
     61    /*
     62     * connect variables to the interface
     63     * look in the global interface for an object named
     64     * "temperature", convert its value to Kelvin, and
     65     * store the value into the address of T.
     66     * look in the global interface for an object named
     67     * "Ef", convert its value to electron Volts and store
     68     * the value into the address of Ef.
     69     * look in the global interface for the columns to
     70     * store data. retrieve them for later use.
     71     */
    6972    Rp_InterfaceConnect("temperature",&T,"units=K",NULL);
    7073    Rp_InterfaceConnect("Ef",&Ef,"units=eV",NULL);
     
    7578    Rp_InterfaceConnect("Energy * 2",y2,NULL);
    7679
    77     // check the global interface for errors
     80    /* check the global interface for errors */
    7881    if (Rp_InterfaceError() != 0) {
    79         // there were errors while retrieving input data values
    80         // dump the traceback
     82        /* there were errors while retrieving input data values */
     83        /* dump the traceback */
    8184        Rp_Outcome *o = Rp_InterfaceOutcome();
    8285        fprintf(stderr, "%s", Rp_OutcomeContext(o));
     
    8588    }
    8689
    87     // do science calculations
     90    /* do science calculations */
    8891    kT = 8.61734e-5 * T;
    8992    Emin = Ef - (10*kT);
     
    103106    }
    104107
    105     // store results in the results table
    106     // add data to the table pointed to by the variable result.
    107     // put the fArr data in the column named "Fermi-Dirac Factor"
    108     // put the EArr data in the column named "Energy"
    109     //
     108    /*
     109     * store results in the results table
     110     * add data to the table pointed to by the variable result.
     111     * put the fArr data in the column named "Fermi-Dirac Factor"
     112     * put the EArr data in the column named "Energy"
     113     */
    110114    Rp_TableColumnStoreDouble(x1,nPts,fArr);
    111115    Rp_TableColumnStoreDouble(y1,nPts,EArr);
     
    113117    Rp_TableColumnStoreDouble(y2,nPts,EArr2);
    114118
    115     // close the global interface
    116     // signal to the graphical user interface that science
    117     // calculations are complete and to display the data
    118     // as described in the views
     119    /*
     120     * close the global interface
     121     * signal to the graphical user interface that science
     122     * calculations are complete and to display the data
     123     * as described in the views
     124     */
    119125    Rp_InterfaceClose();
    120126
Note: See TracChangeset for help on using the changeset viewer.