ReFRACtor
planck.cc
Go to the documentation of this file.
1 #include "planck.h"
2 
3 using namespace blitz;
4 using namespace FullPhysics;
5 
6 // Inform C about the Fortran function we will use
7 extern "C" {
8  void planckfunction(const double* wavenumber, const double* temperature, double* bbfunc, int* smallv, bool* fail, const int* message_len, char* message);
9  void planckfunction_plus(const double* wavenumber, const double* temperature, double* bbfunc, double* deriv_bbfunc, int* smallv, bool* fail, const int* message_len, char* message);
10 }
11 
16 double FullPhysics::planck(double wn, double temperature)
17 {
18  double bbfunc;
19  int smallv;
20  bool fail;
21  const int message_len = 50;
22  char message[message_len];
23 
24  planckfunction(&wn, &temperature, &bbfunc, &smallv, &fail, &message_len, message);
25 
26  if (fail) {
27  Exception err;
28  err << "plankfunction_plus failed with error message: " << message;
29  throw err;
30  }
31 
32  return bbfunc;
33 }
34 
40 AutoDerivative<double> FullPhysics::planck(double wn, double temperature, Array<double, 1>& gradient)
41 {
42  double bbfunc;
43  double deriv_bbfunc;
44  int smallv;
45  bool fail;
46  const int message_len = 50;
47  char message[message_len];
48 
49  planckfunction_plus(&wn, &temperature, &bbfunc, &deriv_bbfunc, &smallv, &fail, &message_len, message);
50 
51  if (fail) {
52  Exception err;
53  err << "plankfunction_plus failed with error message: " << message;
54  throw err;
55  }
56 
57  Array<double, 1> out_gradient(gradient.rows());
58  out_gradient = gradient * deriv_bbfunc;
59 
60  AutoDerivative<double> bbody(bbfunc, out_gradient);
61 
62  return bbody;
63 }
64 
void planckfunction(const double *wavenumber, const double *temperature, double *bbfunc, int *smallv, bool *fail, const int *message_len, char *message)
This is the base of the exception hierarchy for Full Physics code.
Definition: fp_exception.h:16
Apply value function to a blitz array.
double planck(double wn, double temperature)
Computes the black body function value using the planck function for a given wavenumber (cm^-1) and t...
Definition: planck.cc:16
void planckfunction_plus(const double *wavenumber, const double *temperature, double *bbfunc, double *deriv_bbfunc, int *smallv, bool *fail, const int *message_len, char *message)
Contains classes to abstract away details in various Spurr Radiative Transfer software.
Definition: doxygen_python.h:1

Copyright © 2017, California Institute of Technology.
ALL RIGHTS RESERVED.
U.S. Government Sponsorship acknowledged.
Generated Fri Aug 24 2018 15:44:10