Skip to content
Snippets Groups Projects
Commit 9abbb918 authored by Van Herck, Walter's avatar Van Herck, Walter
Browse files

Provide Python translation for InterferenceFunctionHardDisk

parent 39c66205
No related branches found
No related tags found
No related merge requests found
...@@ -38,6 +38,8 @@ public: ...@@ -38,6 +38,8 @@ public:
double getParticleDensity() const override final; double getParticleDensity() const override final;
double radius() const { return m_radius; }
double density() const { return m_density; }
private: private:
InterferenceFunctionHardDisk(const InterferenceFunctionHardDisk& other); InterferenceFunctionHardDisk(const InterferenceFunctionHardDisk& other);
double iff_without_dw(const kvector_t q) const override final; double iff_without_dw(const kvector_t q) const override final;
......
...@@ -30,7 +30,10 @@ namespace { ...@@ -30,7 +30,10 @@ namespace {
bool particleDensityIsProvidedByInterference(const IInterferenceFunction& iff) bool particleDensityIsProvidedByInterference(const IInterferenceFunction& iff)
{ {
if(iff.getName() == BornAgain::InterferenceFunction2DLatticeType || if(iff.getName() == BornAgain::InterferenceFunction2DLatticeType ||
iff.getName() == BornAgain::InterferenceFunction2DParaCrystalType) iff.getName() == BornAgain::InterferenceFunction2DParaCrystalType ||
iff.getName() == BornAgain::InterferenceFunction2DSuperLattice ||
iff.getName() == BornAgain::InterferenceFunctionFinite2DLatticeType ||
iff.getName() == BornAgain::InterferenceFunctionHardDiskType)
return true; return true;
return false; return false;
} }
......
...@@ -17,8 +17,8 @@ ...@@ -17,8 +17,8 @@
#include "IFormFactor.h" #include "IFormFactor.h"
#include "INodeUtils.h" #include "INodeUtils.h"
#include "InterferenceFunctions.h" #include "InterferenceFunctions.h"
#include "Layer.h"
#include "Lattice.h" #include "Lattice.h"
#include "Layer.h"
#include "LayerInterface.h" #include "LayerInterface.h"
#include "LayerRoughness.h" #include "LayerRoughness.h"
#include "Material.h" #include "Material.h"
...@@ -86,11 +86,12 @@ SampleToPython::~SampleToPython() = default; ...@@ -86,11 +86,12 @@ SampleToPython::~SampleToPython() = default;
std::string SampleToPython::defineGetSample() const std::string SampleToPython::defineGetSample() const
{ {
return "def "+getSampleFunctionName()+"():\n" + defineMaterials() + defineLayers() + defineFormFactors() return "def " + getSampleFunctionName() + "():\n" + defineMaterials() + defineLayers()
+ defineParticles() + defineCoreShellParticles() + defineParticleCompositions() + defineFormFactors() + defineParticles() + defineCoreShellParticles()
+ defineLattices() + defineCrystals() + defineMesoCrystals() + defineParticleCompositions() + defineLattices() + defineCrystals()
+ defineParticleDistributions() + defineInterferenceFunctions() + defineParticleLayouts() + defineMesoCrystals() + defineParticleDistributions() + defineInterferenceFunctions()
+ defineRoughnesses() + addLayoutsToLayers() + defineMultiLayers() + "\n\n"; + defineParticleLayouts() + defineRoughnesses() + addLayoutsToLayers()
+ defineMultiLayers() + "\n\n";
} }
const std::map<MATERIAL_TYPES, std::string> factory_names{ const std::map<MATERIAL_TYPES, std::string> factory_names{
...@@ -370,8 +371,8 @@ std::string SampleToPython::defineInterferenceFunctions() const ...@@ -370,8 +371,8 @@ std::string SampleToPython::defineInterferenceFunctions() const
if (dynamic_cast<const InterferenceFunctionNone*>(interference)) if (dynamic_cast<const InterferenceFunctionNone*>(interference))
result << indent() << it->second << " = ba.InterferenceFunctionNone()\n"; result << indent() << it->second << " = ba.InterferenceFunctionNone()\n";
else if (auto p_lattice_1d else if (auto p_lattice_1d =
= dynamic_cast<const InterferenceFunction1DLattice*>(interference)) { dynamic_cast<const InterferenceFunction1DLattice*>(interference)) {
const Lattice1DParameters latticeParameters = p_lattice_1d->getLatticeParameters(); const Lattice1DParameters latticeParameters = p_lattice_1d->getLatticeParameters();
result << indent() << it->second << " = ba.InterferenceFunction1DLattice(" result << indent() << it->second << " = ba.InterferenceFunction1DLattice("
<< printNm(latticeParameters.m_length) << ", " << printNm(latticeParameters.m_length) << ", "
...@@ -383,8 +384,8 @@ std::string SampleToPython::defineInterferenceFunctions() const ...@@ -383,8 +384,8 @@ std::string SampleToPython::defineInterferenceFunctions() const
result << indent() << it->second << "_pdf = ba." << pdf->getName() << "(" result << indent() << it->second << "_pdf = ba." << pdf->getName() << "("
<< argumentList(pdf) << ")\n" << argumentList(pdf) << ")\n"
<< indent() << it->second << ".setDecayFunction(" << it->second << "_pdf)\n"; << indent() << it->second << ".setDecayFunction(" << it->second << "_pdf)\n";
} else if (auto p_para_radial } else if (auto p_para_radial =
= dynamic_cast<const InterferenceFunctionRadialParaCrystal*>(interference)) { dynamic_cast<const InterferenceFunctionRadialParaCrystal*>(interference)) {
result << indent() << it->second << " = ba.InterferenceFunctionRadialParaCrystal(" result << indent() << it->second << " = ba.InterferenceFunctionRadialParaCrystal("
<< printNm(p_para_radial->peakDistance()) << ", " << printNm(p_para_radial->peakDistance()) << ", "
<< printNm(p_para_radial->dampingLength()) << ")\n"; << printNm(p_para_radial->dampingLength()) << ")\n";
...@@ -404,8 +405,8 @@ std::string SampleToPython::defineInterferenceFunctions() const ...@@ -404,8 +405,8 @@ std::string SampleToPython::defineInterferenceFunctions() const
<< argumentList(pdf) << ")\n" << argumentList(pdf) << ")\n"
<< indent() << it->second << ".setProbabilityDistribution(" << it->second << indent() << it->second << ".setProbabilityDistribution(" << it->second
<< "_pdf)\n"; << "_pdf)\n";
} else if (auto p_lattice_2d } else if (auto p_lattice_2d =
= dynamic_cast<const InterferenceFunction2DLattice*>(interference)) { dynamic_cast<const InterferenceFunction2DLattice*>(interference)) {
const Lattice2D& lattice = p_lattice_2d->lattice(); const Lattice2D& lattice = p_lattice_2d->lattice();
result << indent() << it->second << " = ba.InterferenceFunction2DLattice(" result << indent() << it->second << " = ba.InterferenceFunction2DLattice("
<< printNm(lattice.length1()) << ", " << printNm(lattice.length2()) << ", " << printNm(lattice.length1()) << ", " << printNm(lattice.length2()) << ", "
...@@ -420,20 +421,20 @@ std::string SampleToPython::defineInterferenceFunctions() const ...@@ -420,20 +421,20 @@ std::string SampleToPython::defineInterferenceFunctions() const
if (p_lattice_2d->integrationOverXi() == true) if (p_lattice_2d->integrationOverXi() == true)
result << indent() << it->second << ".setIntegrationOverXi(True)\n"; result << indent() << it->second << ".setIntegrationOverXi(True)\n";
} else if (auto p_lattice_2d } else if (auto p_lattice_2d =
= dynamic_cast<const InterferenceFunctionFinite2DLattice*>(interference)) { dynamic_cast<const InterferenceFunctionFinite2DLattice*>(interference)) {
const Lattice2D& lattice = p_lattice_2d->lattice(); const Lattice2D& lattice = p_lattice_2d->lattice();
result << indent() << it->second << " = ba.InterferenceFunctionFinite2DLattice(" result << indent() << it->second << " = ba.InterferenceFunctionFinite2DLattice("
<< printNm(lattice.length1()) << ", " << printNm(lattice.length2()) << ", " << printNm(lattice.length1()) << ", " << printNm(lattice.length2()) << ", "
<< printDegrees(lattice.latticeAngle()) << ", " << printDegrees(lattice.latticeAngle()) << ", "
<< printDegrees(lattice.rotationAngle()) << ", " << printDegrees(lattice.rotationAngle()) << ", "
<< p_lattice_2d->numberUnitCells1() << ", " << p_lattice_2d->numberUnitCells1() << ", " << p_lattice_2d->numberUnitCells2()
<< p_lattice_2d->numberUnitCells2() << ")\n"; << ")\n";
if (p_lattice_2d->integrationOverXi() == true) if (p_lattice_2d->integrationOverXi() == true)
result << indent() << it->second << ".setIntegrationOverXi(True)\n"; result << indent() << it->second << ".setIntegrationOverXi(True)\n";
} else if (auto p_para_2d } else if (auto p_para_2d =
= dynamic_cast<const InterferenceFunction2DParaCrystal*>(interference)) { dynamic_cast<const InterferenceFunction2DParaCrystal*>(interference)) {
std::vector<double> domainSize = p_para_2d->domainSizes(); std::vector<double> domainSize = p_para_2d->domainSizes();
const Lattice2D& lattice = p_para_2d->lattice(); const Lattice2D& lattice = p_para_2d->lattice();
result << indent() << it->second << " = ba.InterferenceFunction2DParaCrystal(" result << indent() << it->second << " = ba.InterferenceFunction2DParaCrystal("
...@@ -462,12 +463,17 @@ std::string SampleToPython::defineInterferenceFunctions() const ...@@ -462,12 +463,17 @@ std::string SampleToPython::defineInterferenceFunctions() const
<< argumentList(pdf) << ")\n"; << argumentList(pdf) << ")\n";
result << indent() << it->second << ".setProbabilityDistributions(" << it->second result << indent() << it->second << ".setProbabilityDistributions(" << it->second
<< "_pdf_1, " << it->second << "_pdf_2)\n"; << "_pdf_1, " << it->second << "_pdf_2)\n";
} else if (auto p_lattice_hd =
dynamic_cast<const InterferenceFunctionHardDisk*>(interference)) {
result << indent() << it->second << " = ba.InterferenceFunctionHardDisk("
<< printNm(p_lattice_hd->radius()) << ", "
<< printDouble(p_lattice_hd->density()) << ")\n";
} else } else
throw Exceptions::NotImplementedException( throw Exceptions::NotImplementedException(
"Bug: ExportToPython::defineInterferenceFunctions() called with unexpected " "Bug: ExportToPython::defineInterferenceFunctions() called with unexpected "
"IInterferenceFunction " "IInterferenceFunction "
+ interference->getName()); + interference->getName());
if (interference->positionVariance()>0.0) { if (interference->positionVariance() > 0.0) {
result << indent() << it->second << ".setPositionVariance(" result << indent() << it->second << ".setPositionVariance("
<< printNm2(interference->positionVariance()) << ")\n"; << printNm2(interference->positionVariance()) << ")\n";
} }
...@@ -591,7 +597,10 @@ std::string SampleToPython::defineMultiLayers() const ...@@ -591,7 +597,10 @@ std::string SampleToPython::defineMultiLayers() const
return result.str(); return result.str();
} }
std::string SampleToPython::indent() const { return " "; } std::string SampleToPython::indent() const
{
return " ";
}
void SampleToPython::setRotationInformation(const IParticle* p_particle, std::string name, void SampleToPython::setRotationInformation(const IParticle* p_particle, std::string name,
std::ostringstream& result) const std::ostringstream& result) const
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment