BornAgain  1.18.0
Simulate and fit neutron and x-ray scattering at grazing incidence
SimulationToPython.cpp
Go to the documentation of this file.
1 // ************************************************************************** //
2 //
3 // BornAgain: simulate and fit scattering at grazing incidence
4 //
5 //! @file Core/Export/SimulationToPython.cpp
6 //! @brief Implements class SimulationToPython.
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2018
11 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************** //
14 
16 #include "Base/Utils/Algorithms.h"
17 #include "Base/Utils/PyFmt.h"
20 #include "Core/Export/INodeUtils.h"
36 #include <iomanip>
37 
38 namespace
39 {
40 const std::string defineSimulate = "def run_simulation():\n"
41  " sample = "
43  + "()\n"
44  " simulation = get_simulation()\n"
45  " simulation.setSample(sample)\n"
46  " simulation.runSimulation()\n"
47  " return simulation.result()\n"
48  "\n\n";
49 
50 //! Returns a function that converts a coordinate to a Python code snippet with appropiate unit
51 std::function<std::string(double)> printFunc(const IDetector* detector)
52 {
53  if (detector->defaultAxesUnits() == Axes::Units::MM)
54  return pyfmt::printDouble;
55  if (detector->defaultAxesUnits() == Axes::Units::RADIANS)
56  return pyfmt::printDegrees;
58  "SimulationToPython::defineMasks() -> Error. Unknown detector units.");
59 }
60 
61 //! returns true if it is (0, -1, 0) vector
62 bool isDefaultDirection(const kvector_t direction)
63 {
64  return algo::almostEqual(direction.x(), 0.0) && algo::almostEqual(direction.y(), -1.0)
65  && algo::almostEqual(direction.z(), 0.0);
66 }
67 
68 } // namespace
69 
70 //! Returns a Python script that sets up a simulation and runs it if invoked as main program.
71 
73  EMainType mainType)
74 {
75  if (simulation.sample() == nullptr)
76  throw std::runtime_error("SimulationToPython::generateSimulationCode() -> Error. "
77  "Simulation is not initialized.");
78 
79  SampleToPython sampleGenerator;
80 
81  return pyfmt::scriptPreamble() + sampleGenerator.generateSampleCode(*simulation.sample())
82  + defineGetSimulation(&simulation) + defineSimulate + defineMain(mainType);
83 }
84 
85 std::string SimulationToPython::defineGetSimulation(const Simulation* simulation) const
86 {
87  std::ostringstream result;
88  result << "def get_simulation():\n";
89 
90  if (auto gisas = dynamic_cast<const GISASSimulation*>(simulation))
91  result << defineGISASSimulation(gisas);
92  else if (auto offspec = dynamic_cast<const OffSpecSimulation*>(simulation))
93  result << defineOffSpecSimulation(offspec);
94  else if (auto spec = dynamic_cast<const SpecularSimulation*>(simulation))
95  result << defineSpecularSimulation(spec);
96  else
97  throw std::runtime_error("SimulationToPython::defineGetSimulation() -> Error. "
98  "Wrong simulation type");
99 
100  result << pyfmt::indent() << "return simulation\n\n\n";
101  return result.str();
102 }
103 
104 std::string SimulationToPython::defineGISASSimulation(const GISASSimulation* simulation) const
105 {
106  std::ostringstream result;
107  result << pyfmt::indent() << "simulation = ba.GISASSimulation()\n";
108  result << defineDetector(simulation);
109  result << defineDetectorResolutionFunction(simulation);
110  result << defineDetectorPolarizationAnalysis(simulation);
111  result << defineGISASBeam(*simulation);
112  result << defineParameterDistributions(simulation);
113  result << defineMasks(simulation);
114  result << defineSimulationOptions(simulation);
115  result << defineBackground(simulation);
116  return result.str();
117 }
118 
120 {
121  std::ostringstream result;
122  result << pyfmt::indent() << "simulation = ba.OffSpecSimulation()\n";
123  result << defineDetector(simulation);
124  result << defineDetectorResolutionFunction(simulation);
125  result << defineDetectorPolarizationAnalysis(simulation);
126  result << defineOffSpecBeam(*simulation);
127  result << defineParameterDistributions(simulation);
128  result << defineMasks(simulation);
129  result << defineSimulationOptions(simulation);
130  result << defineBackground(simulation);
131  return result.str();
132 }
133 
135 {
136  std::ostringstream result;
137  result << pyfmt::indent() << "simulation = ba.SpecularSimulation()\n";
138  result << defineDetectorPolarizationAnalysis(simulation);
139  result << defineSpecularScan(*simulation);
140  result << defineParameterDistributions(simulation);
141  result << defineSimulationOptions(simulation);
142  result << defineBackground(simulation);
143  return result.str();
144 }
145 
146 std::string SimulationToPython::defineDetector(const Simulation* simulation) const
147 {
148  const IDetector* const detector = simulation->instrument().getDetector();
149  if (detector->dimension() != 2)
150  throw Exceptions::RuntimeErrorException("SimulationToPython::defineDetector: "
151  "detector must be two-dimensional for GISAS");
152  std::ostringstream result;
153  result << std::setprecision(12);
154 
155  if (const auto* const det = dynamic_cast<const SphericalDetector*>(detector)) {
156  result << pyfmt::indent() << "simulation.setDetectorParameters(";
157  for (size_t index = 0; index < det->dimension(); ++index) {
158  if (index != 0)
159  result << ", ";
160  result << det->getAxis(index).size() << ", "
161  << pyfmt::printDegrees(det->getAxis(index).getMin()) << ", "
162  << pyfmt::printDegrees(det->getAxis(index).getMax());
163  }
164  result << ")\n";
165  } else if (const auto* const det = dynamic_cast<const RectangularDetector*>(detector)) {
166  result << pyfmt::indent() << "\n";
167  result << pyfmt::indent() << "detector = ba.RectangularDetector(" << det->getNbinsX()
168  << ", " << pyfmt::printDouble(det->getWidth()) << ", " << det->getNbinsY() << ", "
169  << pyfmt::printDouble(det->getHeight()) << ")\n";
170  if (det->getDetectorArrangment() == RectangularDetector::GENERIC) {
171  result << pyfmt::indent() << "detector.setPosition("
172  << pyfmt::printKvector(det->getNormalVector()) << ", "
173  << pyfmt::printDouble(det->getU0()) << ", " << pyfmt::printDouble(det->getV0());
174  if (!isDefaultDirection(det->getDirectionVector()))
175  result << ", " << pyfmt::printKvector(det->getDirectionVector());
176  result << ")\n";
177  } else if (det->getDetectorArrangment() == RectangularDetector::PERPENDICULAR_TO_SAMPLE) {
178  result << pyfmt::indent() << "detector.setPerpendicularToSampleX("
179  << pyfmt::printDouble(det->getDistance()) << ", "
180  << pyfmt::printDouble(det->getU0()) << ", " << pyfmt::printDouble(det->getV0())
181  << ")\n";
182  } else if (det->getDetectorArrangment()
184  result << pyfmt::indent() << "detector.setPerpendicularToDirectBeam("
185  << pyfmt::printDouble(det->getDistance()) << ", "
186  << pyfmt::printDouble(det->getU0()) << ", " << pyfmt::printDouble(det->getV0())
187  << ")\n";
188  } else if (det->getDetectorArrangment()
190  result << pyfmt::indent() << "detector.setPerpendicularToReflectedBeam("
191  << pyfmt::printDouble(det->getDistance()) << ", "
192  << pyfmt::printDouble(det->getU0()) << ", " << pyfmt::printDouble(det->getV0())
193  << ")\n";
194  } else if (det->getDetectorArrangment()
196  result << pyfmt::indent() << "detector.setPerpendicularToReflectedBeam("
197  << pyfmt::printDouble(det->getDistance()) << ")\n";
198  result << pyfmt::indent() << "detector.setDirectBeamPosition("
199  << pyfmt::printDouble(det->getDirectBeamU0()) << ", "
200  << pyfmt::printDouble(det->getDirectBeamV0()) << ")\n";
201  } else
203  "SimulationToPython::defineDetector() -> Error. Unknown alignment.");
204 
205  result << pyfmt::indent() << "simulation.setDetector(detector)\n";
206  } else
207  throw Exceptions::RuntimeErrorException("SimulationToPython::defineDetector() -> Error. "
208  "Unknown detector");
209  if (detector->regionOfInterest()) {
210  result << pyfmt::indent() << "simulation.setRegionOfInterest("
211  << printFunc(detector)(detector->regionOfInterest()->getXlow()) << ", "
212  << printFunc(detector)(detector->regionOfInterest()->getYlow()) << ", "
213  << printFunc(detector)(detector->regionOfInterest()->getXup()) << ", "
214  << printFunc(detector)(detector->regionOfInterest()->getYup()) << ")\n";
215  }
216  result << pyfmt::indent() << "\n";
217  return result.str();
218 }
219 
221 {
222  std::ostringstream result;
223  const IDetector* detector = simulation->instrument().getDetector();
224 
225  if (const IDetectorResolution* p_resfunc = detector->detectorResolution()) {
226  if (auto* p_convfunc = dynamic_cast<const ConvolutionDetectorResolution*>(p_resfunc)) {
227  if (auto* resfunc = dynamic_cast<const ResolutionFunction2DGaussian*>(
228  p_convfunc->getResolutionFunction2D())) {
229  result << pyfmt::indent() << "simulation.setDetectorResolutionFunction(";
230  result << "ba.ResolutionFunction2DGaussian(";
231  result << printFunc(detector)(resfunc->getSigmaX()) << ", ";
232  result << printFunc(detector)(resfunc->getSigmaY()) << "))\n";
233  } else
235  "SimulationToPython::defineDetectorResolutionFunction() -> Error. "
236  "Unknown detector resolution function");
237  } else
239  "SimulationToPython::defineDetectorResolutionFunction() -> Error. "
240  "Not a ConvolutionDetectorResolution function");
241  }
242  return result.str();
243 }
244 
245 std::string
247 {
248  std::ostringstream result;
249  const IDetector* detector = simulation->instrument().getDetector();
250  kvector_t analyzer_direction = detector->detectionProperties().analyzerDirection();
251  double analyzer_efficiency = detector->detectionProperties().analyzerEfficiency();
252  double analyzer_total_transmission =
254 
255  if (analyzer_direction.mag() > 0.0) {
256  std::string direction_name = "analyzer_direction";
257  result << pyfmt::indent() << direction_name << " = kvector_t("
258  << pyfmt::printDouble(analyzer_direction.x()) << ", "
259  << pyfmt::printDouble(analyzer_direction.y()) << ", "
260  << pyfmt::printDouble(analyzer_direction.z()) << ")\n";
261  result << pyfmt::indent() << "simulation.setAnalyzerProperties(" << direction_name << ", "
262  << pyfmt::printDouble(analyzer_efficiency) << ", "
263  << pyfmt::printDouble(analyzer_total_transmission) << ")\n";
264  }
265  return result.str();
266 }
267 
268 std::string SimulationToPython::defineGISASBeam(const GISASSimulation& simulation) const
269 {
270  std::ostringstream result;
271  const Beam& beam = simulation.instrument().getBeam();
272 
273  result << pyfmt::indent() << "simulation.setBeamParameters("
274  << pyfmt::printNm(beam.getWavelength()) << ", " << pyfmt::printDegrees(beam.getAlpha())
275  << ", " << pyfmt::printDegrees(beam.getPhi()) << ")\n";
276 
277  result << defineBeamPolarization(beam);
278  result << defineBeamIntensity(beam);
279 
280  return result.str();
281 }
282 
283 std::string SimulationToPython::defineOffSpecBeam(const OffSpecSimulation& simulation) const
284 {
285  std::ostringstream result;
286  const Beam& beam = simulation.instrument().getBeam();
287 
288  const std::string axis_def = pyfmt::indent() + "alpha_i_axis = ";
289  result << axis_def << simulation.beamAxis()->pyString("rad", axis_def.size()) << "\n";
290 
291  result << pyfmt::indent() << "simulation.setBeamParameters("
292  << pyfmt::printNm(beam.getWavelength()) << ", "
293  << "alpha_i_axis, " << pyfmt::printDegrees(beam.getPhi()) << ")\n";
294 
295  result << defineBeamPolarization(beam);
296  result << defineBeamIntensity(beam);
297  return result.str();
298 }
299 
300 std::string SimulationToPython::defineSpecularScan(const SpecularSimulation& simulation) const
301 {
302  std::ostringstream result;
303  const ISpecularScan* scan = simulation.dataHandler();
304  if (!scan)
305  throw std::runtime_error("Error SimulationToPython::defineSpecularScan: passed simulation "
306  "does not contain any scan");
307  result << *scan << "\n";
308 
309  result << pyfmt::indent() << "simulation.setScan(scan)\n";
310  result << defineBeamIntensity(simulation.instrument().getBeam());
311  result << "\n";
312  return result.str();
313 }
314 
315 std::string SimulationToPython::defineBeamPolarization(const Beam& beam) const
316 {
317  std::ostringstream result;
318  auto bloch_vector = beam.getBlochVector();
319  if (bloch_vector.mag() > 0.0) {
320  std::string beam_polarization = "beam_polarization";
321  result << pyfmt::indent() << beam_polarization << " = kvector_t("
322  << pyfmt::printDouble(bloch_vector.x()) << ", "
323  << pyfmt::printDouble(bloch_vector.y()) << ", "
324  << pyfmt::printDouble(bloch_vector.z()) << ")\n";
325  result << pyfmt::indent() << "simulation.setBeamPolarization(" << beam_polarization
326  << ")\n";
327  }
328  return result.str();
329 }
330 
331 std::string SimulationToPython::defineBeamIntensity(const Beam& beam) const
332 {
333  std::ostringstream result;
334  double beam_intensity = beam.getIntensity();
335  if (beam_intensity > 0.0)
336  result << pyfmt::indent() << "simulation.setBeamIntensity("
337  << pyfmt::printScientificDouble(beam_intensity) << ")\n";
338  return result.str();
339 }
340 
342 {
343  std::ostringstream result;
344  const std::vector<ParameterDistribution>& distributions =
346  if (distributions.empty())
347  return "";
348  for (size_t i = 0; i < distributions.size(); ++i) {
349  std::string main_par_name = distributions[i].getMainParameterName();
350 
351  std::string mainParUnits = ParameterUtils::poolParameterUnits(*simulation, main_par_name);
352 
353  size_t nbr_samples = distributions[i].getNbrSamples();
354  double sigma_factor = distributions[i].getSigmaFactor();
355 
356  std::string s_distr = "distr_" + std::to_string(i + 1);
357  result << pyfmt::indent() << s_distr << " = "
358  << pyfmt2::printDistribution(*distributions[i].getDistribution(), mainParUnits)
359  << "\n";
360 
361  result << pyfmt::indent() << "simulation.addParameterDistribution(\"" << main_par_name
362  << "\", " << s_distr << ", " << nbr_samples << ", "
363  << pyfmt::printDouble(sigma_factor)
364  << pyfmt::printRealLimitsArg(distributions[i].getLimits(), mainParUnits) << ")\n";
365  }
366  return result.str();
367 }
368 
369 std::string SimulationToPython::defineMasks(const Simulation* simulation) const
370 {
371  std::ostringstream result;
372  result << std::setprecision(12);
373 
374  const IDetector* detector = simulation->instrument().getDetector();
375  const DetectorMask* detectorMask = detector->detectorMask();
376  if (detectorMask && detectorMask->numberOfMasks()) {
377  result << "\n";
378  for (size_t i_mask = 0; i_mask < detectorMask->numberOfMasks(); ++i_mask) {
379  bool mask_value(false);
380  const IShape2D* shape = detectorMask->getMaskShape(i_mask, mask_value);
381  result << pyfmt2::representShape2D(pyfmt::indent(), shape, mask_value,
382  printFunc(detector));
383  }
384  result << "\n";
385  }
386  return result.str();
387 }
388 
389 std::string SimulationToPython::defineSimulationOptions(const Simulation* simulation) const
390 {
391  std::ostringstream result;
392  result << std::setprecision(12);
393 
394  const SimulationOptions& options = simulation->getOptions();
395  if (options.getHardwareConcurrency() != options.getNumberOfThreads())
396  result << pyfmt::indent() << "simulation.getOptions().setNumberOfThreads("
397  << options.getNumberOfThreads() << ")\n";
398  if (options.isIntegrate())
399  result << pyfmt::indent() << "simulation.getOptions().setMonteCarloIntegration(True, "
400  << options.getMcPoints() << ")\n";
401  if (options.useAvgMaterials())
402  result << pyfmt::indent() << "simulation.getOptions().setUseAvgMaterials(True)\n";
403  if (options.includeSpecular())
404  result << pyfmt::indent() << "simulation.getOptions().setIncludeSpecular(True)\n";
405  return result.str();
406 }
407 
408 std::string SimulationToPython::defineBackground(const Simulation* simulation) const
409 {
410  std::ostringstream result;
411 
412  auto p_bg = simulation->background();
413  if (auto p_constant_bg = dynamic_cast<const ConstantBackground*>(p_bg)) {
414  if (p_constant_bg->backgroundValue() > 0.0) {
415  result << pyfmt::indent() << "background = ba.ConstantBackground("
416  << pyfmt::printScientificDouble(p_constant_bg->backgroundValue()) << ")\n";
417  result << pyfmt::indent() << "simulation.setBackground(background)\n";
418  }
419  } else if (dynamic_cast<const PoissonNoiseBackground*>(p_bg)) {
420  result << pyfmt::indent() << "background = ba.PoissonNoiseBackground()\n";
421  result << pyfmt::indent() << "simulation.setBackground(background)\n";
422  }
423  return result.str();
424 }
425 
427 {
428  std::string result;
429  if (mainType == RUN_SIMULATION) {
430  result = "if __name__ == '__main__': \n"
431  " result = run_simulation()\n"
432  " ba.plot_simulation_result(result)\n";
433  } else if (mainType == SAVE_DATA) {
434  result = "if __name__ == '__main__': \n"
435  " result = run_simulation()\n"
436  " import sys\n"
437  " if len(sys.argv)<2:\n"
438  " exit(\"File name is required\")\n"
439  " ba.IntensityDataIOFactory.writeSimulationResult(result, sys.argv[1])\n";
440  } else {
441  throw std::runtime_error("SimulationToPython::defineMain() -> Error. Unknown main type.");
442  }
443  return result;
444 }
Defines and implements namespace algo with some algorithms.
Defines class ConstantBackground.
Defines class ConvolutionDetectorResolution.
Defines class FootprintGauss.
Defines class FootprintSquare.
Defines class GISASSimulation.
Defines namespace INodeUtils.
Declares and implements pure virtual class ISpecularScan.
Defines class OffSpecSimulation.
Defines namespace ParameterUtils.
Defines class PoissonNoiseBackground.
Defines namespace pyfmt2.
Defines functions in namespace pyfmt.
Defines functions in namespace pyfmt.
Defines class RectangularDetector.
Defines class RegionOfInterest.
Defines class ResolutionFunction2DGaussian.
Defines class SampleToPython.
Defines class SimulationToPython.
Defines class SpecularSimulation.
Defines class SphericalDetector.
double mag() const
Returns magnitude of the vector.
T z() const
Returns z-component in cartesian coordinate system.
Definition: BasicVector3D.h:68
T y() const
Returns y-component in cartesian coordinate system.
Definition: BasicVector3D.h:66
T x() const
Returns x-component in cartesian coordinate system.
Definition: BasicVector3D.h:64
Beam defined by wavelength, direction and intensity.
Definition: Beam.h:27
double getWavelength() const
Definition: Beam.h:69
double getAlpha() const
Definition: Beam.h:70
double getIntensity() const
Returns the beam intensity in neutrons/sec.
Definition: Beam.h:45
kvector_t getBlochVector() const
Definition: Beam.cpp:118
double getPhi() const
Definition: Beam.h:71
Class representing a constant background signal.
Convolutes the intensity in 1 or 2 dimensions with a resolution function.
double analyzerEfficiency() const
will always return positive value
double analyzerTotalTransmission() const
kvector_t analyzerDirection() const
Retrieve the analyzer characteristics.
Collection of detector masks.
Definition: DetectorMask.h:29
const IShape2D * getMaskShape(size_t mask_index, bool &mask_value) const
size_t numberOfMasks() const
const Distributions_t & getDistributions() const
Main class to run a Grazing-Incidence Small-Angle Scattering simulation.
virtual std::string pyString(const std::string &units, size_t offset) const =0
Interface for detector resolution algorithms.
Abstract detector interface.
Definition: IDetector.h:36
virtual const DetectorMask * detectorMask() const =0
Returns detector masks container.
size_t dimension() const
Returns actual dimensionality of the detector (number of defined axes)
Definition: IDetector.cpp:44
const IDetectorResolution * detectorResolution() const
Returns a pointer to detector resolution object.
Definition: IDetector.cpp:142
virtual const RegionOfInterest * regionOfInterest() const =0
Returns region of interest if exists.
virtual Axes::Units defaultAxesUnits() const
Return default axes units.
Definition: IDetector.h:101
const DetectionProperties & detectionProperties() const
Returns detection properties.
Definition: IDetector.h:93
Basic class for all shapes in 2D.
Definition: IShape2D.h:27
Pure virtual base class for all types of specular scans.
Definition: ISpecularScan.h:31
Beam & getBeam()
Definition: Instrument.h:44
const IDetector * getDetector() const
Definition: Instrument.cpp:121
Main class to run an off-specular simulation.
const IAxis * beamAxis() const
Returns axis of the beam.
Class representing Poisson noise on top of the scattered intensity.
A flat rectangular detector with axes and resolution function.
double getYlow() const
double getYup() const
double getXlow() const
double getXup() const
Simple gaussian two-dimensional resolution function.
Generates Python code snippet from domain (C++) objects representing sample construction.
std::string generateSampleCode(const MultiLayer &multilayer)
Collect the different options for simulation.
size_t getMcPoints() const
bool includeSpecular() const
unsigned getHardwareConcurrency() const
unsigned getNumberOfThreads() const
bool isIntegrate() const
bool useAvgMaterials() const
std::string defineOffSpecSimulation(const OffSpecSimulation *simulation) const
std::string defineDetectorPolarizationAnalysis(const Simulation *simulation) const
std::string defineSpecularSimulation(const SpecularSimulation *simulation) const
@ SAVE_DATA
main function saves intensity data
@ RUN_SIMULATION
main function runs simulation
std::string defineOffSpecBeam(const OffSpecSimulation &simulation) const
std::string generateSimulationCode(const Simulation &simulation, EMainType mainType)
Returns a Python script that sets up a simulation and runs it if invoked as main program.
std::string defineSimulationOptions(const Simulation *simulation) const
std::string defineGISASBeam(const GISASSimulation &simulation) const
std::string defineDetectorResolutionFunction(const Simulation *simulation) const
std::string defineSpecularScan(const SpecularSimulation &simulation) const
std::string defineParameterDistributions(const Simulation *simulation) const
std::string defineBeamIntensity(const Beam &beam) const
std::string defineGetSimulation(const Simulation *simulation) const
std::string defineBeamPolarization(const Beam &beam) const
std::string defineBackground(const Simulation *simulation) const
std::string defineGISASSimulation(const GISASSimulation *simulation) const
std::string defineMain(EMainType mainType=RUN_SIMULATION)
std::string defineMasks(const Simulation *simulation) const
std::string defineDetector(const Simulation *simulation) const
Pure virtual base class of OffSpecularSimulation, GISASSimulation and SpecularSimulation.
Definition: Simulation.h:38
const SimulationOptions & getOptions() const
Definition: Simulation.h:92
const Instrument & instrument() const
Definition: Simulation.h:55
const IBackground * background() const
Definition: Simulation.h:75
const DistributionHandler & getDistributionHandler() const
Definition: Simulation.h:89
const MultiLayer * sample() const
Definition: Simulation.cpp:247
Main class to run a specular simulation.
const ISpecularScan * dataHandler() const
Returns internal data handler.
A spherical detector with axes and resolution function.
std::string poolParameterUnits(const IParameterized &node, const std::string &parName)
Returns units of main parameter.
bool almostEqual(double a, double b)
Returns true if two doubles agree within machine epsilon.
Definition: Algorithms.h:30
std::function< std::string(double)> printFunc(const IDetector *detector)
Returns a function that converts a coordinate to a Python code snippet with appropiate unit.
bool isDefaultDirection(const kvector_t direction)
returns true if it is (0, -1, 0) vector
std::string printDistribution(const IDistribution1D &par_distr, const std::string &units)
Prints distribution with constructor parameters in given units.
Definition: PyFmt2.cpp:117
std::string representShape2D(const std::string &indent, const IShape2D *ishape, bool mask_value, std::function< std::string(double)> printValueFunc)
Returns fixed Python code snippet that defines the function "runSimulation".
Definition: PyFmt2.cpp:38
std::string printNm(double input)
Definition: PyFmt.cpp:57
std::string getSampleFunctionName()
Definition: PyFmt.cpp:33
std::string printDegrees(double input)
Definition: PyFmt.cpp:94
std::string printDouble(double input)
Definition: PyFmt.cpp:43
std::string printKvector(const kvector_t value)
Definition: PyFmt.cpp:133
std::string printScientificDouble(double input)
Definition: PyFmt.cpp:74
std::string indent(size_t width)
Returns a string of blanks with given width.
Definition: PyFmt.cpp:141
std::string printRealLimitsArg(const RealLimits &limits, const std::string &units)
Prints RealLimits in the form of argument (in the context of ParameterDistribution and similar).
Definition: PyFmtLimits.cpp:61
std::string scriptPreamble()
Definition: PyFmt.cpp:24