36 template <
typename SimulatorT >
39 typedef typename SimulatorT::device_type DeviceType;
40 typedef typename DeviceType::mesh_type MeshType;
42 typedef typename viennagrid::result_of::point<MeshType>::type PointType;
43 typedef typename viennagrid::result_of::const_cell_range<MeshType>::type CellContainer;
44 typedef typename viennagrid::result_of::iterator<CellContainer>::type CellIterator;
46 DeviceType
const & device = sim.device();
48 std::ofstream writer(filename.c_str());
52 viennashe::log::error() <<
"write_to_gnuplot(): Cannot open the file '" << filename <<
"'" << std::endl;
56 writer <<
"## ViennaSHE - gnuplot output of '" << name <<
"' in SI units unless otherwise noted" << std::endl;
57 writer <<
"## x_i are the vertex coordinates (meter) and a_i are the quantity values " << std::endl;
61 const std::size_t dim =
static_cast<std::size_t
>(PointType::dim);
63 CellContainer cells(device.mesh());
65 for (CellIterator cit = cells.begin();
70 std::vector<double> values(1);
71 reg.cell_based.get(name).fill_single(std::size_t(cit->id().get()), values);
73 if (values.size() == 0)
continue;
79 for (std::size_t i = 0; i < dim; ++i) writer <<
" x_" << i <<
" ";
80 for (std::size_t i = 0; i < values.size(); ++i) writer <<
" a_" << i <<
" ";
86 for (std::size_t i = 0; i < dim; ++i) writer << viennagrid::centroid(*cit)[i] <<
" ";
87 for (std::size_t i = 0; i < values.size(); ++i) writer << values[i] <<
" ";
93 <<
"' (can be viewed with e.g. gnuplot)" << std::endl;
103 template <
typename SimulatorT >
106 typedef typename SimulatorT::device_type DeviceType;
107 typedef typename DeviceType::mesh_type MeshType;
109 typedef typename viennagrid::result_of::point<MeshType>::type PointType;
110 typedef typename viennagrid::result_of::const_cell_range<MeshType>::type CellContainer;
111 typedef typename viennagrid::result_of::iterator<CellContainer>::type CellIterator;
113 typedef typename SimulatorT::edf_type EDFType;
114 typedef typename SimulatorT::generalized_edf_type GeneralizedEDFType;
120 viennashe::log::warning() <<
"Warning! write_she_to_gnuplot(): Electron SHE Quantities cannot be written to file. There are no quantities to write!" << std::endl;
125 viennashe::log::warning() <<
"Warning! write_she_to_gnuplot(): Hole SHE Quantities cannot be written to file. There are no quantities to write!" << std::endl;
129 DeviceType
const & device = sim.device();
132 EDFType edf = sim.edf(ctype);
133 GeneralizedEDFType gedf = sim.generalized_edf(ctype);
136 std::ofstream writer(filename.c_str());
143 writer <<
"## ViennaSHE - gnuplot output of SHE "
145 <<
" Quantities in SI units unless otherwise noted" << std::endl;
146 writer <<
"## x_i are the vertex coordinates (meter) " << std::endl;
150 CellContainer cells(device.mesh());
151 for (CellIterator cit = cells.begin();
159 for (std::size_t i = 0; i < static_cast<std::size_t>(PointType::dim); ++i) writer <<
" x_" << i <<
" ";
160 writer <<
" energy edf generalized_edf dos vg" << std::endl;
165 for (std::size_t index_H = 1; index_H < sim.quantities().carrier_distribution_function(ctype).get_value_H_size()-1; ++index_H)
167 const double eps = sim.quantities().carrier_distribution_function(ctype).get_kinetic_energy(*cit, index_H);
168 const double dos = disp.density_of_states(eps);
169 const double velo = disp.velocity(eps);
173 for (std::size_t i = 0; i < static_cast<std::size_t>(PointType::dim); ++i) writer << viennagrid::centroid(*cit)[i] <<
" ";
174 writer << eps <<
" " << edf(*cit, eps, index_H) <<
" " << gedf(*cit, eps, index_H) <<
" " << dos <<
" " << velo << std::endl;
184 <<
"' (can be viewed with e.g. gnuplot)" << std::endl;
203 viennashe::log::error() <<
"ERROR! write_to_gnuplot: The quantity regiser (reg) must not be NULL!" << std::endl;
206 if (filename == NULL)
218 viennashe::log::error() <<
"ERROR! write_to_gnuplot(): The simulator (sim) must be valid!" << std::endl;
224 viennashe::log::error() <<
"ERROR! write_to_gnuplot(): The quantity '" << name <<
"' does not exist!" << std::endl;
231 libviennashe::write_to_gnuplot(*(int_sim->
sim1d), *int_reg, std::string(name), std::string(filename));
235 libviennashe::write_to_gnuplot(*(int_sim->
simq2d), *int_reg, std::string(name), std::string(filename));
239 libviennashe::write_to_gnuplot(*(int_sim->
simt2d), *int_reg, std::string(name), std::string(filename));
243 libviennashe::write_to_gnuplot(*(int_sim->
simh3d), *int_reg, std::string(name), std::string(filename));
247 libviennashe::write_to_gnuplot(*(int_sim->
simt3d), *int_reg, std::string(name), std::string(filename));
255 catch (std::exception
const & ex)
278 viennashe::log::error() <<
"ERROR! viennashe_write_she_results_to_gnuplot: The quantity regiser (reg) must not be NULL!" << std::endl;
281 if (filename == NULL)
283 viennashe::log::error() <<
"ERROR! viennashe_write_she_results_to_gnuplot: The filename must not be NULL!" << std::endl;
294 viennashe::log::error() <<
"ERROR! viennashe_write_she_results_to_gnuplot(): The simulator (sim) must be valid!" << std::endl;
303 libviennashe::write_she_to_gnuplot(*(int_sim->
sim1d), ctype, std::string(filename));
307 libviennashe::write_she_to_gnuplot(*(int_sim->
simq2d), ctype, std::string(filename));
311 libviennashe::write_she_to_gnuplot(*(int_sim->
simt2d), ctype, std::string(filename));
315 libviennashe::write_she_to_gnuplot(*(int_sim->
simh3d), ctype, std::string(filename));
319 libviennashe::write_she_to_gnuplot(*(int_sim->
simt3d), ctype, std::string(filename));
323 viennashe::log::error() <<
"ERROR! viennashe_write_she_results_to_gnuplot(): Unkown grid type!" << std::endl;
329 viennashe::log::error() <<
"ERROR! viennashe_write_she_results_to_gnuplot: UNKOWN ERROR!" << std::endl;
bool has_quan(std::string const &name) const
Returns true if a quantity is registered.
The main SHE configuration class. To be adjusted by the user for his/her needs.
viennashe::physics::dispersion_proxy dispersion_relation(viennashe::carrier_type_id ctype) const
Returns the dispersion relation for electrons.
Exception which is thrown if a file cannot be opened.
A proxy object for a dispersion relation. Does NOT take ownership of the provided pointer!
The internal C++ namespace of the library.
reg
This is DD, so we do not need to give any inital guess.
logger< true > error()
Used to log errors. The logging level is logERROR.
logger< true > warning()
Used to log warnings. The logging level is logWARNING.
logger< true > info()
Used to log infos. The logging level is logINFO.
carrier_type_id
Enumeration type for selecting the carrier type.
VIENNASHE_EXPORT viennasheErrorCode viennashe_write_to_gnuplot(viennashe_quan_register reg, char const *name, char const *filename)
VIENNASHE_EXPORT viennasheErrorCode viennashe_write_she_results_to_gnuplot(viennashe_quan_register reg, viennashe_carrier_ids ctype, char const *filename)
viennashe_quan_register_impl * viennashe_quan_register
viennashe_carrier_ids
Enum of available charge carrier types.
Routines to wrap ViennaSHE quantities (doping, potential, distribution functions, ....
C++ to C wrapper of the quantity registry.
libviennashe::quantity::quantitiy_register cell_based
viennashe_simulator_impl * int_sim
Register for vertex based quantities.
Internal C++ to C wrapper for the simulator. Has typedefs and destructor.
Contains all viennashe includes and most of the C++/C-wrappers. Contains macros.