diff --git a/App/src/TestFormFactors.cpp b/App/src/TestFormFactors.cpp index 4da3da0fd46c3ba6f5fd642e4fd857b4b5da7d83..206dac8ef2724b96d43aa452b9fcb16a3c5c4451 100644 --- a/App/src/TestFormFactors.cpp +++ b/App/src/TestFormFactors.cpp @@ -157,71 +157,6 @@ void TestFormFactors::run_isgisaxs_simulation(IFormFactor *p_form_factor) "this_"+mp_form_factor->getName().substr(10)+"_BA.ima"); } -//void TestFormFactors::execute() -//{ - // // building simulation - // Simulation simulation(mp_options); - // simulation.setDetectorParameters(100, 0.0*Units::degree, 2.0*Units::degree, - // 100, 0.0*Units::degree, 2.0*Units::degree, - // true); - // simulation.setBeamParameters(1.0*Units::angstrom, 0.2*Units::degree, - // 0.0*Units::degree); - - //building sample - // MultiLayer multi_layer; - // const IMaterial *p_air_material = MaterialManager::getHomogeneousMaterial("Air", 0.0, 0.0); - // const IMaterial *p_substrate_material = - // MaterialManager::getHomogeneousMaterial("Substrate", 6e-6, 2e-8); - // Layer air_layer; - // air_layer.setMaterial(p_air_material); - // Layer substrate_layer; - // substrate_layer.setMaterial(p_substrate_material); - // const IMaterial *particle_material = - // MaterialManager::getHomogeneousMaterial("Particle", 6e-4, 2e-8); - - // R=H=5nm W=2R, no rotation of particles angle =54.73deg - // For Cone6 and prism6 radius = 2./sqrt(3.)R_{IsGiSaXs} - //double angle = Units::deg2rad(54.73 ); - // double radius = 5.0*Units::nanometer; - // double half_side = radius; - // double height = 5.0*Units::nanometer; - // double length = 2.*radius; - // double width = 2.*length; - // double side_hex_base = 2./sqrt(3.)*radius; - - //FormFactorCylinder ff(radius, height); - //FormFactorBox ff(length, width, height); - // FormFactorCone ff(radius, height, angle); - //FormFactorCone6 ff(side_hex_base, height, angle); - //FormFactorFullSphere ff(radius); - //FormFactorParallelepiped ff(length, height); - //FormFactorPrism3 ff(length, height); - //FormFactorPrism6 ff(side_hex_base, height); - //FormFactorPyramid ff(length, height, angle); - //FormFactorTruncatedSphere ff(radius, height); - //FormFactorTetrahedron ff(10.*Units::nanometer,5.*Units::nanometer, angle); - - // ParticleLayout particle_layout( new Particle(particle_material,ff)); - // particle_layout.addInterferenceFunction(new InterferenceFunctionNone()); - // air_layer.setDecoration(particle_layout); - // multi_layer.addLayer(air_layer); - // // building simulation - // simulation.setSample(multi_layer); - // simulation.runSimulation(); - - //OutputDataIOFactory::writeIntensityData(*simulation.getOutputData(), "this_cylinder_BA.ima"); - //OutputDataIOFactory::writeIntensityData(*simulation.getOutputData(), "this_box_BA.ima"); - // OutputDataIOFactory::writeIntensityData(*simulation.getOutputData(), "this_cone_BA.ima"); - //OutputDataIOFactory::writeIntensityData(*simulation.getOutputData(), "this_cone6_BA.ima"); - //OutputDataIOFactory::writeIntensityData(*simulation.getOutputData(), "this_full_sphere_BA.ima"); - //OutputDataIOFactory::writeIntensityData(*simulation.getOutputData(), "this_parallelepiped_BA.ima"); - //OutputDataIOFactory::writeIntensityData(*simulation.getOutputData(), "this_prism3_BA.ima"); - //OutputDataIOFactory::writeIntensityData(*simulation.getOutputData(), "this_prism6_BA.ima"); - //OutputDataIOFactory::writeIntensityData(*simulation.getOutputData(), "this_pyramid_BA.ima"); - //OutputDataIOFactory::writeIntensityData(*simulation.getOutputData(), "this_sphere_BA.ima"); - //OutputDataIOFactory::writeIntensityData(*simulation.getOutputData(), "this_tetrahedron_BA.ima"); -//} - void TestFormFactors::finalise() { std::vector< CompareStruct > tocompare; diff --git a/App/src/TestPolarizedMeso.cpp b/App/src/TestPolarizedMeso.cpp index b0b1126ae4925279c1c25685c39fe8a2fcef9482..8d33a320e6e41872bab98718691761a4b48c9e85 100644 --- a/App/src/TestPolarizedMeso.cpp +++ b/App/src/TestPolarizedMeso.cpp @@ -82,13 +82,6 @@ MultiLayer* TestPolarizedMeso::createSample() const m_surface_filling_ratio/m_meso_width/m_meso_width; kvector_t magnetic_field(3.4, 3.4, 3.4); HomogeneousMagneticMaterial particle_material("nanoparticle",2.84e-5, 4.7e-7, magnetic_field); -// const IMaterial *p_particle_material = -// MaterialManager::getHomogeneousMaterial("nanoparticle", -// 2.84e-5, 4.7e-7); -// FormFactorDecoratorDebyeWaller -// ff_meso(ff_cyl.clone(), -// m_sigma_meso_height*m_sigma_meso_height/2.0, -// m_sigma_meso_radius*m_sigma_meso_radius/2.0); // Create multilayer MultiLayer *p_multi_layer = new MultiLayer(); diff --git a/Core/PythonAPI/inc/PythonCoreExposer.h b/Core/PythonAPI/inc/PythonCoreExposer.h index 104bf0dda91f4f7d52758ceb2399673728124062..0805e90ec15bb567622a52fa45021a9570dc278e 100644 --- a/Core/PythonAPI/inc/PythonCoreExposer.h +++ b/Core/PythonAPI/inc/PythonCoreExposer.h @@ -29,20 +29,16 @@ namespace pyplusplus { namespace aliases { using namespace Geometry; - //typedef Geometry::BasicVector3D<double > kvector_t; typedef BasicVector3D<double > kvector_t; typedef std::vector<kvector_t > vector_kvector_t; typedef BasicVector3D<std::complex<double> > cvector_t; typedef std::vector<cvector_t > vector_cvector_t; typedef std::vector<DiffuseParticleInfo *> vector_DiffuseParticleInfoPtr_t; typedef std::vector<IFormFactor *> vector_IFormFactorPtr_t; - //typedef ISingleton<MaterialManager> MaterialManagerSingleton_t; typedef StochasticParameter<double> StochasticParameter_t; typedef OutputData<double > IntensityData; typedef std::vector<int > vector_integer_t; typedef std::vector<unsigned long int > vector_longinteger_t; - //typedef std::vector<std::string > vector_string_t; - //typedef boost::shared_ptr<class ISampleBuilder > SampleBuilder_t; } } diff --git a/Core/PythonAPI/inc/PythonModule.h b/Core/PythonAPI/inc/PythonModule.h index 39bd96354d3f1c2f1ac0c42cf269c90dd7c243b7..de3f50ae6298455f7c244b21afdc65cccb09d68f 100644 --- a/Core/PythonAPI/inc/PythonModule.h +++ b/Core/PythonAPI/inc/PythonModule.h @@ -48,7 +48,6 @@ //#include "Layer.h" //#include "LayerDecorator.h" //#include "LayerRoughness.h" -//#include "MaterialManager.h" //#include "MesoCrystal.h" //#include "MultiLayer.h" //#include "Particle.h" diff --git a/GUI/coregui/Models/MaterialManager.cpp b/GUI/coregui/Models/MaterialManager.cpp deleted file mode 100644 index 2c6e84d6220ca73b14a7f4b342127cf7ae353f0b..0000000000000000000000000000000000000000 --- a/GUI/coregui/Models/MaterialManager.cpp +++ /dev/null @@ -1,261 +0,0 @@ -// ************************************************************************** // -// -// BornAgain: simulate and fit scattering at grazing incidence -// -//! @file Samples/src/MaterialManager.cpp -//! @brief Implements class MaterialManager. -//! -//! @homepage http://apps.jcns.fz-juelich.de/BornAgain -//! @license GNU General Public License v3 or higher (see COPYING) -//! @copyright Forschungszentrum Jülich GmbH 2013 -//! @authors Scientific Computing Group at MLZ Garching -//! @authors C. Durniak, G. Pospelov, W. Van Herck, J. Wuttke -// -// ************************************************************************** // - -#include "MaterialManager.h" - -#include "HomogeneousMagneticMaterial.h" -#include "Exceptions.h" -#include "MessageService.h" -#include "Macros.h" -GCC_DIAG_OFF(strict-aliasing); -#include <boost/thread.hpp> -GCC_DIAG_ON(strict-aliasing); - -//! Materials database type. -typedef std::map<std::string, IMaterial*> materials_t; - -//! Clear database. -void MaterialManager::clear() { - static boost::mutex single_mutex; - boost::unique_lock<boost::mutex> single_lock( single_mutex ); - for(materials_t::iterator - it = m_materials.begin(); it!= m_materials.end(); ++it) { - if( (*it).second ) - delete (*it).second; - } - m_materials.clear(); -} - -//! Returns material. -const IMaterial *MaterialManager::this_getMaterial(const std::string& name) -{ - static boost::mutex single_mutex; - boost::unique_lock<boost::mutex> single_lock( single_mutex ); - materials_t::const_iterator pos = m_materials.find(name); - if( pos != m_materials.end()) { - return pos->second; - } else { - return 0; - } -} - -//! Creates material, and add into database using name of material as identifier. -const IMaterial *MaterialManager::this_getHomogeneousMaterial( - const std::string& name, const complex_t& refractive_index) -{ - check_refractive_index(refractive_index); - - static boost::mutex single_mutex; - boost::unique_lock<boost::mutex> single_lock( single_mutex ); - const IMaterial *mat = getMaterial(name); - if( mat ) { - // check if user is trying to create material - // with same name but different parameters - if(!mat->isScalarMaterial()) { - throw LogicErrorException( - "MaterialManager::this_getHomogeneousMaterial()" - " -> Attempt to make existing magnetic material" - " non-magnetic one. Material name '"+mat->getName()+"'."); - } - const HomogeneousMaterial *old = - dynamic_cast<const HomogeneousMaterial *>(mat); - if(old->getRefractiveIndex() != refractive_index) { - HomogeneousMaterial *non_const_mat = - const_cast<HomogeneousMaterial *>(old); - non_const_mat->setRefractiveIndex(refractive_index); - msglog(MSG::WARNING) << - "MaterialManager::addHomogeneousMaterial()" << - "-> Redefining refractive index for material '" << - name << "'"; - } - return mat; - } else { - IMaterial *hmat = new HomogeneousMaterial(name, refractive_index); - m_materials[name] = hmat; - return hmat; - } -} - -//! Creates material, and add into database using name of material as identifier. -const IMaterial *MaterialManager::this_getHomogeneousMaterial( - const std::string& name, - double refractive_index_delta, - double refractive_index_beta) -{ - return this_getHomogeneousMaterial( - name, complex_t(1.0-refractive_index_delta, refractive_index_beta)); -} - -//! Creates magnetic material, and add into database using name of material -//! as identifier. -const IMaterial* MaterialManager::this_getHomogeneousMagneticMaterial( - const std::string& name, const complex_t& refractive_index, - const kvector_t& magnetic_field) -{ - check_refractive_index(refractive_index); - - static boost::mutex single_mutex; - boost::unique_lock<boost::mutex> single_lock( single_mutex ); - const IMaterial *mat = getMaterial(name); - if( mat ) { - // check if user is trying to create material - // with same name but different parameters - if(mat->isScalarMaterial()) { - throw LogicErrorException( - "MaterialManager::this_getHomogeneousMagneticMaterial()" - " -> Attempt to make existing non-magnetic material" - " magnetic one. Material name '"+mat->getName()+"'."); - } - - const HomogeneousMagneticMaterial *mold = - dynamic_cast<const HomogeneousMagneticMaterial *>(mat); - - if(mold->getMagneticField() != magnetic_field) { - HomogeneousMagneticMaterial *non_const_mat = - const_cast<HomogeneousMagneticMaterial *>(mold); - non_const_mat->setMagneticField(magnetic_field); - msglog(MSG::WARNING) << - "MaterialManager::addHomogeneousMagneticMaterial()" << - "-> Redefining magnetic field for material '" << name << "'"; - } - if(mold->getRefractiveIndex() != refractive_index) { - HomogeneousMagneticMaterial *non_const_mat = - const_cast<HomogeneousMagneticMaterial *>(mold); - non_const_mat->setRefractiveIndex(refractive_index); - msglog(MSG::WARNING) << - "MaterialManager::addHomogeneousMagneticMaterial()" << - "-> Redefining refractive index for material '" << name << "'"; - } - - return mat; - } else { - IMaterial *hmat = new HomogeneousMagneticMaterial(name, - refractive_index, magnetic_field); - m_materials[name] = hmat; - return hmat; - } -} - -//! Creates magnetic material, and add into database using name of material -//! as identifier. -const IMaterial* MaterialManager::this_getHomogeneousMagneticMaterial( - const std::string& name, double refractive_index_delta, - double refractive_index_beta, const kvector_t& magnetic_field) -{ - return this_getHomogeneousMagneticMaterial( - name, complex_t(1.0-refractive_index_delta, refractive_index_beta), - magnetic_field); -} - -const IMaterial* MaterialManager::this_getInvertedMaterial( - const std::string& name) -{ - const IMaterial *p_orig_material = getMaterial(name); - if (!p_orig_material) return 0; - const HomogeneousMagneticMaterial *p_magn_material = - dynamic_cast<const HomogeneousMagneticMaterial *>(p_orig_material); - if (!p_magn_material) return p_orig_material; - std::string new_name = name + "_inv"; - return this_getHomogeneousMagneticMaterial(new_name, - p_magn_material->getRefractiveIndex(), - -p_magn_material->getMagneticField()); -} - -//! Dump this to stream. -void MaterialManager::print(std::ostream& ostr) const -{ - ostr << typeid(*this).name() << " " << this << - " nmaterials:" << m_materials.size() << std::endl; - for(materials_t::const_iterator - it = m_materials.begin(); it!= m_materials.end(); ++it) { - const IMaterial *mat = (*it).second; - ostr << *mat << std::endl; - } -} - -//! Checks refractive index for consistency -void MaterialManager::check_refractive_index(const complex_t &index) -{ - bool isConsistent(true); - if( (index.imag() < 0.0) || (index.real() <= 0.0) ) isConsistent = false; - - if( !isConsistent ) { - msglog(MSG::ERROR) << "MaterialManager::check_refractive_index() -> " - << "Suspicious refractive index " << index; - } -} - -//! set new material name -bool MaterialManager::setMaterialName(const std::string &old_name, - const std::string &new_name) -{ - std::cout << "MaterialManager::setMaterialName() -> " << std::endl; - if( !getMaterial(old_name) ) { - msglog(MSG::ERROR) << "MaterialManager::setMaterialName() -> " - << "No material with name " << old_name; - return false; - } - - if( getMaterial(new_name) ) { - msglog(MSG::ERROR) << "MaterialManager::setMaterialName() -> " - << "Existingh name " << new_name; - return false; - } - - IMaterial *mat = m_materials[old_name]; - mat->setName(new_name); - m_materials.erase(old_name); - m_materials[new_name] = mat; - return true; -} - - -bool MaterialManager::deleteMaterial(const std::string &name) -{ - std::cout << "MaterialManager::deleteMaterial() -> " << std::endl; - if( !getMaterial(name) ) { - msglog(MSG::ERROR) << "MaterialManager::deleteMaterial() -> " - << "No material with name " << name; - return false; - } - - delete m_materials[name]; - m_materials.erase(name); - return true; -} - - -bool MaterialManager::setMaterialRefractiveIndex( - const std::string &name, const complex_t &index) -{ - std::cout << "MaterialManager::setMaterialRefractiveIndex() -> " << - std::endl; - if( !getMaterial(name) ) { - msglog(MSG::ERROR) << "MaterialManager::setMaterialRefractiveIndex() -> " - << "No material with name " << name; - return false; - } - - HomogeneousMaterial *mat = dynamic_cast<HomogeneousMaterial *>( - m_materials[name]); - if( !mat ) { - msglog(MSG::ERROR) << "MaterialManager::setMaterialRefractiveIndex() -> " - << "can't cast to HomogeneousMaterial' " << name; - return false; - } - mat->setRefractiveIndex(index); - return true; -} - diff --git a/GUI/coregui/Models/MaterialManager.h b/GUI/coregui/Models/MaterialManager.h deleted file mode 100644 index c5a1ddb11dc224104ab3edf0ca3fd4db2de82b9f..0000000000000000000000000000000000000000 --- a/GUI/coregui/Models/MaterialManager.h +++ /dev/null @@ -1,142 +0,0 @@ -// ************************************************************************** // -// -// BornAgain: simulate and fit scattering at grazing incidence -// -//! @file Samples/inc/MaterialManager.h -//! @brief Defines class MaterialManager. -//! -//! @homepage http://apps.jcns.fz-juelich.de/BornAgain -//! @license GNU General Public License v3 or higher (see COPYING) -//! @copyright Forschungszentrum Jülich GmbH 2013 -//! @authors Scientific Computing Group at MLZ Garching -//! @authors C. Durniak, G. Pospelov, W. Van Herck, J. Wuttke -// -// ************************************************************************** // - -#ifndef MATERIALMANAGER_H -#define MATERIALMANAGER_H - -#include "Exceptions.h" -#include "ISingleton.h" -#include "IMaterial.h" -#include <iostream> -#include <string> -#include <map> - -//! @class MaterialManager -//! @ingroup materials -//! @brief Manager of materials used in simulation. -//! -//! Maintains a database of materials, and provides a common and unique -//! interface for material creation and access. - - -class BA_CORE_API_ MaterialManager: public ISingleton<MaterialManager> -{ -public: - typedef std::map<std::string, IMaterial*> materials_t; - typedef materials_t::iterator iterator; - typedef materials_t::const_iterator const_iterator; - - virtual ~MaterialManager() { clear(); } - - //! Returns material from database. - static const IMaterial *getMaterial(const std::string& name) - { return instance().this_getMaterial(name); } - - //! Adds and returns material to database. - static const IMaterial *getHomogeneousMaterial( - const std::string& name, const complex_t& refractive_index) - { return instance().this_getHomogeneousMaterial(name, refractive_index); } - - //! Adds and returns material to database. - static const IMaterial *getHomogeneousMaterial( - const std::string& name, - double refractive_index_delta, - double refractive_index_beta) - { return instance().this_getHomogeneousMaterial( - name, refractive_index_delta, refractive_index_beta); } - - //! Adds and returns magnetic material to database. - static const IMaterial *getHomogeneousMagneticMaterial( - const std::string& name, const complex_t& refractive_index, - const kvector_t &magnetic_field) - { return instance().this_getHomogeneousMagneticMaterial(name, - refractive_index, magnetic_field); } - - //! Adds and returns magnetic material to database. - static const IMaterial *getHomogeneousMagneticMaterial( - const std::string& name, - double refractive_index_delta, - double refractive_index_beta, - const kvector_t &magnetic_field) - { return instance().this_getHomogeneousMagneticMaterial( - name, refractive_index_delta, refractive_index_beta, - magnetic_field); } - - //! Adds and returns material with inverted magnetic field (if present) to - //! database. The new material is based on the material with the given name - static const IMaterial *getInvertedMaterial( - const std::string& name) - { return instance().this_getInvertedMaterial(name); } - - //! returns number of materials - static int getNumberOfMaterials() { return instance(). - this_getNumberOfMaterials(); } - - //! Sends class description to stream. - friend std::ostream& operator<<( - std::ostream& ostr, const MaterialManager& m) - { m.print(ostr); return ostr; } - - //! access to container begin - iterator begin() { return m_materials.begin(); } - - //! access to container begin - iterator end() { return m_materials.end(); } - - //! set new material name - bool setMaterialName(const std::string &old_name, const std::string &new_name); - - //! set new material refractive index - bool setMaterialRefractiveIndex(const std::string &name, const complex_t &index); - - //! delete material - bool deleteMaterial(const std::string &name); - -protected: - MaterialManager(){} - friend class ISingleton<MaterialManager >; - - //! Clear database. - void clear(); - - //! Dump this to stream. - virtual void print(std::ostream& ostr) const; - - materials_t m_materials; //!< our database - -private: - const IMaterial *this_getMaterial(const std::string& name); - const IMaterial *this_getHomogeneousMaterial( - const std::string& name, const complex_t& refractive_index); - const IMaterial *this_getHomogeneousMaterial( - const std::string& name, - double refractive_index_delta, double refractive_index_beta); - const IMaterial *this_getHomogeneousMagneticMaterial( - const std::string& name, const complex_t& refractive_index, - const kvector_t &magnetic_field); - const IMaterial *this_getHomogeneousMagneticMaterial( - const std::string& name, - double refractive_index_delta, double refractive_index_beta, - const kvector_t &magnetic_field); - const IMaterial *this_getInvertedMaterial( - const std::string& name); - int this_getNumberOfMaterials() const { return (int)m_materials.size(); } - - void check_refractive_index(const complex_t &index); -}; - -#endif /* MATERIALMANAGER_H */ - -