diff --git a/Core/Computation/GISASSpecularComputation.cpp b/Core/Computation/GISASSpecularComputation.cpp index a25adc44777f9cd20fa51217d56ebda37754a213..b339b94f008a094bd22137c6397b4f925007a835 100644 --- a/Core/Computation/GISASSpecularComputation.cpp +++ b/Core/Computation/GISASSpecularComputation.cpp @@ -28,8 +28,10 @@ void GISASSpecularComputation::compute(SimulationElement& elem) const return; complex_t R = m_fresnel_map->getInCoefficients(elem, 0)->getScalarR(); double sin_alpha_i = std::abs(std::sin(elem.getAlphaI())); - if (sin_alpha_i == 0.0) - sin_alpha_i = 1.0; + if (sin_alpha_i == 0.0) { + elem.setIntensity(0); + return; + } const double solid_angle = elem.solidAngle(); if (solid_angle <= 0.0) return; diff --git a/Core/Computation/ParticleLayoutComputation.cpp b/Core/Computation/ParticleLayoutComputation.cpp index 25ed1933dedf6eba76a5b7e0ea2e709a0aa3cc19..b2d5342cd043d17357766b52cff09a91f74be0b3 100644 --- a/Core/Computation/ParticleLayoutComputation.cpp +++ b/Core/Computation/ParticleLayoutComputation.cpp @@ -58,11 +58,6 @@ ParticleLayoutComputation::~ParticleLayoutComputation() = default; void ParticleLayoutComputation::compute(SimulationElement& elem) const { - const double alpha_f = elem.getAlphaMean(); - const size_t n_layers = m_layout.numberOfSlices(); - if (n_layers > 1 && alpha_f < 0) - return; // zero for transmission with multilayers (n>1) # TODO: support transmission GISAS - elem.addIntensity(m_interference_function_strategy->evaluate(elem) * m_layout.surfaceDensity()); } diff --git a/Examples/scatter2d/DodecahedraSAS.py b/Examples/scatter2d/DodecahedraSAS.py new file mode 100755 index 0000000000000000000000000000000000000000..8ef9e943dac614c86a67632541895a006ed2e841 --- /dev/null +++ b/Examples/scatter2d/DodecahedraSAS.py @@ -0,0 +1,47 @@ +#!/usr/bin/env python3 +""" +Basic example for regular small-angle scattering (SAS). +Sample is a dilute assembly of ordered dodecahedra. +""" + +import numpy as np +import bornagain as ba +from bornagain import deg, nm + + +def get_sample(): + m_vacuum = ba.HomogeneousMaterial("Vacuum", 0.0, 0.0) + m_solution = ba.HomogeneousMaterial("Solution", 6e-6, 2e-8) + m_particle = ba.HomogeneousMaterial("Particle", 6e-4, 2e-8) + + ff = ba.FormFactorDodecahedron(2*nm) + particle = ba.Particle(m_particle, ff) + layout = ba.ParticleLayout() + layout.addParticle(particle) + + solution_layer = ba.Layer(m_solution, 1000*nm) + # TODO: make intensity proportional to thickness, + # https://github.com/scgmlz/BornAgain/issues/1222 + solution_layer.addLayout(layout) + + multi_layer = ba.MultiLayer() + multi_layer.addLayer(ba.Layer(m_vacuum)) + multi_layer.addLayer(solution_layer) + multi_layer.addLayer(ba.Layer(m_vacuum)) + return multi_layer + + +def get_simulation(sample): + beam = ba.Beam(1, 0.1*nm, ba.Direction(90*deg, 0.0*deg)) + detWid = 500 + detPix = 200 + det = ba.RectangularDetector(detPix, detWid, detPix, detWid) + det.setPerpendicularToDirectBeam(2000, detWid/2, detWid/2) + return ba.GISASSimulation(beam, sample, det) + + +if __name__ == '__main__': + import ba_plot + sample = get_sample() + simulation = get_simulation(sample) + ba_plot.run_and_plot(simulation) diff --git a/Tests/Examples/CMakeLists.txt b/Tests/Examples/CMakeLists.txt index 4a6864af219a1e6e73f282f559a5bd022b425fa2..8a1bc96fa7efd758d0127e1841466cbb090ed963 100644 --- a/Tests/Examples/CMakeLists.txt +++ b/Tests/Examples/CMakeLists.txt @@ -86,6 +86,7 @@ test_example(scatter2d/CylindersInBA 2e-10) test_example(scatter2d/CylindersInDWBA 2e-10) test_example(scatter2d/CylindersWithSizeDistribution 2e-10) test_example(scatter2d/DetectorResolutionFunction 2e-10) +test_example(scatter2d/DodecahedraSAS.py 2e-10) test_example(scatter2d/HalfSpheresInAverageTopLayer 2e-10) test_example(scatter2d/HexagonalLatticesWithBasis 2e-10) test_example(scatter2d/Interference1DRadialParaCrystal 2e-10) diff --git a/Tests/ReferenceData/ExamplesMini/DodecahedraSAS.int.gz b/Tests/ReferenceData/ExamplesMini/DodecahedraSAS.int.gz new file mode 100644 index 0000000000000000000000000000000000000000..b1c1f796cba69790a6087585254ad9c4523513a7 Binary files /dev/null and b/Tests/ReferenceData/ExamplesMini/DodecahedraSAS.int.gz differ diff --git a/Tests/ReferenceData/Std/RectDetWithRoi.int.gz b/Tests/ReferenceData/Std/RectDetWithRoi.int.gz index 839f8758bf33fcd0b5a0a6a679a3e3a076507f7e..b699596c86db5ffb1657a09cddd7a2c4b6493b52 100644 Binary files a/Tests/ReferenceData/Std/RectDetWithRoi.int.gz and b/Tests/ReferenceData/Std/RectDetWithRoi.int.gz differ diff --git a/cmake/configurables/CTestCustom.cmake.in b/cmake/configurables/CTestCustom.cmake.in index 8e2f7ba5b604c36ec2c59d79e87b681c963fca2b..8a2bbc08a560a6a8daa7cbb33783f4f92f094113 100644 --- a/cmake/configurables/CTestCustom.cmake.in +++ b/cmake/configurables/CTestCustom.cmake.in @@ -1,2 +1,3 @@ set(CTEST_CUSTOM_POST_TEST "echo For details, see the log files in Testing/Temporary/LastTest.log -More info at http://bornagainproject.org/documentation/troubleshooting#ctest") +More info at http://bornagainproject.org/documentation/howto/troubleshooting, + section: Functional test (ctest) fails")