From 39ab16c02609e334a663cfebb93f81775fbf0821 Mon Sep 17 00:00:00 2001 From: pospelov <pospelov@fz-juelich.de> Date: Tue, 12 Jun 2012 17:43:31 +0200 Subject: [PATCH] Fix in MultiLayer to change layer thickness, inc directory. --- App/inc/TestFresnelCoeff.h | 12 +++- App/src/StandardSamples.cpp | 53 ++++----------- App/src/TestFresnelCoeff.cpp | 128 ++++++++++++++++++----------------- Core/inc/Convolve.h | 2 +- Core/inc/MultiLayer.h | 3 + Core/src/Convolve.cpp | 9 +-- Core/src/MultiLayer.cpp | 25 +++++-- 7 files changed, 119 insertions(+), 113 deletions(-) diff --git a/App/inc/TestFresnelCoeff.h b/App/inc/TestFresnelCoeff.h index 9096b2794d9..069f7d6f0e5 100644 --- a/App/inc/TestFresnelCoeff.h +++ b/App/inc/TestFresnelCoeff.h @@ -32,9 +32,17 @@ public: void execute(); - void draw(); - private: + //! calculate fresnel coefficients for several standard multi-layer samples + void test_standard(); + //! draw results of the test + void draw_standard(); + + //! calculate fresnel coefficients for multi-layer with different roughnesses + void test_roughness(); + //! draw result of the test + void draw_roughness(); + MultiLayer *m_sample; //!< pointer to multilayer sample OutputData<OpticalFresnel::MultiLayerCoeff_t > *m_coeffs; //!< output data structure }; diff --git a/App/src/StandardSamples.cpp b/App/src/StandardSamples.cpp index dbc72f2f62c..4b7393862df 100644 --- a/App/src/StandardSamples.cpp +++ b/App/src/StandardSamples.cpp @@ -24,13 +24,6 @@ ISample *StandardSamples::AirOnSubstrate() Layer lSubstrate; lSubstrate.setMaterial(mSubstrate,0); - -// LayerRoughness roughness; -// roughness.setSigma(1.0*Units::nanometer); -// roughness.setHurstParameter(0.3); -// roughness.setLatteralCorrLength(5000.*Units::nanometer); -// mySample->addLayerWithTopRoughness(lSubstrate, roughness); - mySample->addLayer(lSubstrate); return mySample; @@ -58,13 +51,6 @@ ISample *StandardSamples::SubstrateOnSubstrate() Layer lSubstrate; lSubstrate.setMaterial(mSubstrate,0); - -// LayerRoughness roughness; -// roughness.setSigma(1.0*Units::nanometer); -// roughness.setHurstParameter(0.3); -// roughness.setLatteralCorrLength(5000.*Units::nanometer); -// mySample->addLayerWithTopRoughness(lSubstrate, roughness); - mySample->addLayer(lSubstrate); return mySample; @@ -100,12 +86,17 @@ ISample *StandardSamples::SimpleMultilayer() // adding layers mySample->addLayer(lAmbience); + LayerRoughness roughness; + roughness.setSigma(0.0*Units::nanometer); + roughness.setHurstParameter(0.3); + roughness.setLatteralCorrLength(5000*Units::nanometer); + const unsigned nrepetitions = 2; for(unsigned i=0; i<nrepetitions; ++i) { - mySample->addLayer(lAg1); - mySample->addLayer(lCr1); + mySample->addLayerWithTopRoughness(lAg1, roughness); + mySample->addLayerWithTopRoughness(lCr1, roughness); } - mySample->addLayer(lSubstrate); + mySample->addLayerWithTopRoughness(lSubstrate, roughness); return mySample; } @@ -216,29 +207,11 @@ ISample *StandardSamples::MultilayerOffspecTestcase2a() /* ************************************************************************* */ ISample *StandardSamples::MultilayerOffspecTestcase2b() { - MaterialManager &matManager = MaterialManager::instance(); - const IMaterial *mAmbience = matManager.addHomogeneousMaterial("ambience",complex_t(1.0, 0.0) ); - const IMaterial *mSubstrate = matManager.addHomogeneousMaterial("substrate", complex_t(1.0-15e-6, 0) ); - - MultiLayer *mySample = new MultiLayer; - - Layer lAmbience; - lAmbience.setMaterial(mAmbience, 0); - mySample->addLayer(lAmbience); - - LayerRoughness roughness; - roughness.setSigma(0.5*Units::nanometer); - roughness.setHurstParameter(0.3); - roughness.setLatteralCorrLength(500.*Units::nanometer); - - Layer lAir; - lAir.setMaterial(mAmbience, 0.01*Units::nanometer); - mySample->addLayerWithTopRoughness(lAir, roughness); - - Layer lSubstrate; - lSubstrate.setMaterial(mSubstrate,0); - mySample->addLayerWithTopRoughness(lSubstrate, roughness); - + MultiLayer *myOrigSample = dynamic_cast<MultiLayer *>(StandardSamples::MultilayerOffspecTestcase2a()); + MultiLayer *mySample = myOrigSample->clone(); + delete myOrigSample; + // changing thickness of middle layer + mySample->setLayerThickness(1, 0.01*Units::nanometer); return mySample; } diff --git a/App/src/TestFresnelCoeff.cpp b/App/src/TestFresnelCoeff.cpp index 7dad07e8a34..cfa18d8a576 100644 --- a/App/src/TestFresnelCoeff.cpp +++ b/App/src/TestFresnelCoeff.cpp @@ -28,29 +28,40 @@ TestFresnelCoeff::TestFresnelCoeff() /* ************************************************************************* */ -//! generation of set of Fresnel Coefficients for several standard samples +//! test fresnel coefficients /* ************************************************************************* */ void TestFresnelCoeff::execute() { std::cout << "TestFresnelCoeff::execute() -> Info." << std::endl; + // calculate fresnel coefficients for several standard multi-layer samples + test_standard(); + + // calculate fresnel coefficients for multi-layer with different roughnesses + test_roughness(); +} + + +/* ************************************************************************* */ +//! calculate fresnel coefficients for several standard multi-layer samples +/* ************************************************************************* */ +void TestFresnelCoeff::test_standard() +{ std::vector<std::string > snames; snames.push_back("AirOnSubstrate"); snames.push_back("SubstrateOnSubstrate"); snames.push_back("SimpleMultilayer"); -// snames.push_back("MultilayerOffspecTestcase1a"); +// snames.push_back("MultilayerOffspecTestcase2a"); +// snames.push_back("MultilayerOffspecTestcase2b"); // loop over standard samples defined in SampleFactory and StandardSamples for(size_t i_sample=0; i_sample<snames.size(); i_sample++){ m_sample = dynamic_cast<MultiLayer *>(SampleFactory::instance().createItem(snames[i_sample])); m_coeffs = new OutputData<OpticalFresnel::MultiLayerCoeff_t >; - m_coeffs->addAxis(std::string("alpha_i"), 0.0*Units::degree, 2.0*Units::degree, 2000); - m_coeffs->resetIndex(); - while (m_coeffs->hasNext()) - { + while (m_coeffs->hasNext()) { double alpha_i = m_coeffs->getCurrentValueOfAxis<double>("alpha_i"); kvector_t kvec = kvector_t::LambdaAlphaPhi(1.54*Units::angstrom, -alpha_i, 0.0); @@ -61,7 +72,7 @@ void TestFresnelCoeff::execute() } // alpha_i - draw(); + draw_standard(); delete m_sample; delete m_coeffs; @@ -69,48 +80,12 @@ void TestFresnelCoeff::execute() } // i_sample } -//void TestFresnelCoeff::execute() -//{ -// std::cout << "TestFresnelCoeff::execute() -> Info." << std::endl; -// -// m_sample = -// dynamic_cast<MultiLayer *>(SampleFactory::instance().createItem(2)); -// -// m_coeffs = new OutputData<OpticalFresnel::MultiLayerCoeff_t>; -// -// NamedVector<double> *alpha_axis = new NamedVector<double>( -// std::string("alpha_i"), 0.0 * Units::degree, -// 2.0 * Units::degree, 3); -// m_coeffs->addAxis(alpha_axis); -// -// MultiIndex &index = m_coeffs->getIndex(); -// while (!index.endPassed()) -// { -// size_t index_y = index.getCoordinate("alpha_i"); -// double alpha_i = (*alpha_axis)[index_y]; -// kvector_t kvec = kvector_t::LambdaAlphaPhi(0.04 * Units::angstrom, -// -alpha_i, 0.0); -// -// OpticalFresnel::MultiLayerCoeff_t coeffs; -// OpticalFresnel::execute(*m_sample, kvec, coeffs); -// -// m_coeffs->currentValue() = coeffs; -// -// ++index; -// } // alpha_i -// -// draw(); -// -// delete m_sample; -// delete m_coeffs; -//} - - /* ************************************************************************* */ -//! drawing fresnel coefficients in a layer as a function of alpha +//! draw fresnel coefficients for several standard multi-layer samples as a +//! function of alpha /* ************************************************************************* */ -void TestFresnelCoeff::draw() +void TestFresnelCoeff::draw_standard() { static int ncall = 0; @@ -140,26 +115,24 @@ void TestFresnelCoeff::draw() OpticalFresnel::MultiLayerCoeff_t coeffs = m_coeffs->next(); // debug printing - size_t index_alpha = i_point; - if( index_alpha%100==0 ) { - std::cout << "alpha_i: " << index_alpha << " " <<std::setprecision(20) << alpha_i << std::endl; - for(size_t i_layer=0; i_layer<nlayers; ++i_layer ) { - std::cout << std::setprecision(12) << " L:" << i_layer +// size_t index_alpha = i_point; +// if( index_alpha%100==0 ) { +// std::cout << "alpha_i: " << index_alpha << " " <<std::setprecision(20) << alpha_i << std::endl; +// for(size_t i_layer=0; i_layer<nlayers; ++i_layer ) { +// std::cout << std::setprecision(12) << " L:" << i_layer // << " kz:" << coeffs[i_layer].kz/10. // << " rt:" // << coeffs[i_layer].r // << coeffs[i_layer].t // << coeffs[i_layer].rb // << coeffs[i_layer].tb - << "X:" << coeffs[i_layer].X - << "R:" << coeffs[i_layer].R - << "T:" << coeffs[i_layer].T - << std::endl; - - //if(index_alpha%100==0) std::cout << " L:" << i_layer << " R:" << coeffs[i_layer].R << " T:" << coeffs[i_layer].T << std::endl; - } - } - +// << "X:" << coeffs[i_layer].X +// << "R:" << coeffs[i_layer].R +// << "T:" << coeffs[i_layer].T +// << std::endl; +// //if(index_alpha%100==0) std::cout << " L:" << i_layer << " R:" << coeffs[i_layer].R << " T:" << coeffs[i_layer].T << std::endl; +// } +// } // Filling graphics for R,T as a function of alpha_i for(size_t i_layer=0; i_layer<nlayers; ++i_layer ) { @@ -172,8 +145,7 @@ void TestFresnelCoeff::draw() double sum; if(coeffs[0].kz.real()!=0.0) { sum = std::norm(coeffs[0].R) + std::norm(coeffs[nlast].T)*coeffs[nlast].kz.real()/coeffs[0].kz.real(); - } - else { + } else { sum = 1.0; std::cout << "Re(k_{z,0}) = 0 for alpha_i = " << alpha_i << std::endl; std::cout << " and Re(k_{z,N+1}) = " << coeffs[nlast].kz.real() << std::endl; @@ -256,6 +228,38 @@ void TestFresnelCoeff::draw() +/* ************************************************************************* */ +//! calculate fresnel coefficients for several standard multi-layer samples +/* ************************************************************************* */ +void TestFresnelCoeff::test_roughness() +{ +// m_sample = dynamic_cast<MultiLayer *>(SampleFactory::instance().createItem("SimpleMultilayer")); + +// double a_roughness[]={0.0,1.0,10.0,100.0}; + +// // loop over standard samples defined in SampleFactory and StandardSamples +// for(size_t i_rough=0; i_rough<sizeof(a_roughness)/sizeof(double); i_rough++){ + +// for(int i_interface=0; i_interface<m_sample) + +// m_coeffs = new OutputData<OpticalFresnel::MultiLayerCoeff_t >; +// m_coeffs->addAxis(std::string("alpha_i"), 0.0*Units::degree, 2.0*Units::degree, 2000); +// m_coeffs->resetIndex(); +// while (m_coeffs->hasNext()) { +// double alpha_i = m_coeffs->getCurrentValueOfAxis<double>("alpha_i"); +// kvector_t kvec = kvector_t::LambdaAlphaPhi(1.54*Units::angstrom, -alpha_i, 0.0); + +// OpticalFresnel::MultiLayerCoeff_t coeffs; +// OpticalFresnel::execute(*m_sample, kvec, coeffs); + +// m_coeffs->next() = coeffs; + +// } // alpha_i + + +} + + ///* **************************************************************************** //Creates some multilayer system, runs calculation of Fresnel R,T coefficients for //all layers, makes plots. diff --git a/Core/inc/Convolve.h b/Core/inc/Convolve.h index 0bc75d5b803..9405f3ef2b4 100644 --- a/Core/inc/Convolve.h +++ b/Core/inc/Convolve.h @@ -97,7 +97,7 @@ private: double *out_kernel; // result of fourier transformation of kernel double *dst_fft; // result of production of FFT(source) and FFT(kernel) int h_dst, w_dst; // size of resulting array - double *dst; // The array containing the result +// double *dst; // The array containing the result int h_offset, w_offset; // offsets to copy result into output arrays fftw_plan p_forw_src; fftw_plan p_forw_kernel; diff --git a/Core/inc/MultiLayer.h b/Core/inc/MultiLayer.h index 45eb3131c13..d4e695126c1 100644 --- a/Core/inc/MultiLayer.h +++ b/Core/inc/MultiLayer.h @@ -87,6 +87,9 @@ public: //! fourier transform of the correlation function of roughnesses between the interfaces double getCrossCorrSpectralFun(const kvector_t &kvec, int j, int k) const; + //! change thickness of layer + void setLayerThickness(size_t i_layer, double thickness); + private: //! hiding copy constructor & assignment operator MultiLayer(const MultiLayer &); diff --git a/Core/src/Convolve.cpp b/Core/src/Convolve.cpp index 78f616c4c43..a5fadc5f9b7 100644 --- a/Core/src/Convolve.cpp +++ b/Core/src/Convolve.cpp @@ -21,7 +21,8 @@ MathFunctions::Convolve::~Convolve() MathFunctions::Convolve::Workspace::Workspace() : h_src(0), w_src(0), h_kernel(0), w_kernel(0), - w_fftw(0), h_fftw(0), in_src(0), out_src(0), in_kernel(0), out_kernel(0), dst_fft(0), h_dst(0), w_dst(0), dst(0), + w_fftw(0), h_fftw(0), in_src(0), out_src(0), in_kernel(0), out_kernel(0), dst_fft(0), h_dst(0), w_dst(0), + //dst(0), h_offset(0), w_offset(0), p_forw_src(NULL), p_forw_kernel(NULL), p_back(NULL) { @@ -56,8 +57,8 @@ void MathFunctions::Convolve::Workspace::clear() if(dst_fft) delete[] dst_fft; dst_fft=0; - if(dst) delete[] dst; - dst=0; + //if(dst) delete[] dst; + //dst=0; h_offset = 0; w_offset = 0; @@ -233,7 +234,7 @@ void MathFunctions::Convolve::init(int h_src, int w_src, int h_kernel, int w_ker ws.out_kernel = (double*) fftw_malloc(sizeof(fftw_complex) * ws.h_fftw * (ws.w_fftw/2+1)); ws.dst_fft = new double[ws.h_fftw * ws.w_fftw]; - ws.dst = new double[ws.h_dst * ws.w_dst]; + //ws.dst = new double[ws.h_dst * ws.w_dst]; // Initialization of the plans ws.p_forw_src = fftw_plan_dft_r2c_2d(ws.h_fftw, ws.w_fftw, ws.in_src, (fftw_complex*)ws.out_src, FFTW_ESTIMATE); diff --git a/Core/src/MultiLayer.cpp b/Core/src/MultiLayer.cpp index 40ce61e6dc7..aab90f811d9 100644 --- a/Core/src/MultiLayer.cpp +++ b/Core/src/MultiLayer.cpp @@ -141,10 +141,10 @@ void MultiLayer::addLayer(const Layer &p_child) } -/* ************************************************************************* */ -//! Correlation function of roughnesses between the interfaces -//! j,k - indexes of layers in multilayer whose bottom interfaces we are considering -/* ************************************************************************* */ +///* ************************************************************************* */ +////! Correlation function of roughnesses between the interfaces +////! j,k - indexes of layers in multilayer whose bottom interfaces we are considering +///* ************************************************************************* */ //double MultiLayer::getCrossCorrFun(const kvector_t &kvec, int j, int k) const //{ // double z_j = getLayerBottomZ(j); @@ -176,3 +176,20 @@ double MultiLayer::getCrossCorrSpectralFun(const kvector_t &kvec, int j, int k) double corr = 0.5*( (sigma_k/sigma_j)*rough_j.getSpectralFun(kvec) + (sigma_j/sigma_k)*rough_k.getSpectralFun(kvec) ) * std::exp( -1*std::abs(z_j-z_k)/m_crossCorrLength ); return corr; } + + +/* ************************************************************************* */ +//! change layer thickness +/* ************************************************************************* */ +void MultiLayer::setLayerThickness(size_t i_layer, double thickness) +{ + m_layers[ check_layer_index(i_layer) ]->setThickness(thickness); + // recalculating z-coordinates of layers + m_layers_z.clear(); + m_layers_z.push_back(0.0); + for(size_t il=1; il<getNumberOfLayers(); il++){ + m_layers_z.push_back(m_layers_z.back() - m_layers[ check_layer_index(il) ]->getThickness() ); + } +} + + -- GitLab