Example #1
0
    static inline void apply(nodes_container_type & additional_nodes,
                             Node & n,
                             Box & n_box,
                             parameters_type const& parameters,
                             Translator const& translator,
                             Allocators & allocators)
    {
        // TODO - consider creating nodes always with sufficient memory allocated

        // create additional node, use auto ptr for automatic destruction on exception
        node_auto_ptr second_node(rtree::create_node<Allocators, Node>::apply(allocators), allocators);     // MAY THROW, STRONG (N: alloc)
        // create reference to the newly created node
        Node & n2 = rtree::get<Node>(*second_node);

        // NOTE: thread-safety
        // After throwing an exception by redistribute_elements the original node may be not changed or
        // both nodes may be empty. In both cases the tree won't be valid r-tree.
        // The alternative is to create 2 (or more) additional nodes here and store backup info
        // in the original node, then, if exception was thrown, the node would always have more than max
        // elements.
        // The alternative is to use moving semantics in the implementations of redistribute_elements,
        // it will be possible to throw from boost::move() in the case of e.g. static size nodes.

        // redistribute elements
        Box box2;
        redistribute_elements<
            Value,
            Options,
            Translator,
            Box,
            Allocators,
            typename Options::redistribute_tag
        >::apply(n, n2, n_box, box2, parameters, translator, allocators);                                   // MAY THROW (V, E: alloc, copy, copy)

        // check numbers of elements
        BOOST_GEOMETRY_INDEX_ASSERT(parameters.get_min_elements() <= rtree::elements(n).size() &&
            rtree::elements(n).size() <= parameters.get_max_elements(),
            "unexpected number of elements");
        BOOST_GEOMETRY_INDEX_ASSERT(parameters.get_min_elements() <= rtree::elements(n2).size() &&
            rtree::elements(n2).size() <= parameters.get_max_elements(),
            "unexpected number of elements");

        // return the list of newly created nodes (this algorithm returns one)
        additional_nodes.push_back(rtree::make_ptr_pair(box2, second_node.get()));                           // MAY THROW, STRONG (alloc, copy)

        // release the ptr
        second_node.release();
    }
Example #2
0
// Defines the parameters for the ising simulation
void ising_sim::define_parameters(parameters_type & parameters) {
    // If the parameters are restored, they are already defined
    if (parameters.is_restored()) {
        return;
    }
    
    // Adds the parameters of the base class
    alps::mcbase::define_parameters(parameters);
    // Adds the convenience parameters (for save/load)
    // followed by the ising specific parameters
    alps::define_convenience_parameters(parameters)
        .description("1D ising simulation")
        .define<int>("length", 50, "lenth of the periodic ising chain")
        .define<int>("sweeps", 1000, "maximum number of sweeps")
        .define<int>("thermalization", "number of sweeps for thermalization")
        .define<double>("temperature", "temperature of the system");
}
Example #3
0
sge::sprite::state::object<
	StateChoices
>::object(
	render_device &_renderer,
	parameters_type const &_parameters
)
:
	renderer_(
		_renderer
	),
	elements_(
		sge::sprite::state::detail::make_objects<
			StateChoices
		>(
			_renderer,
			_parameters.elements()
		)
	)
{
}
Example #4
0
void hybridization::define_parameters(parameters_type & parameters) {
    // If the parameters are restored, they exist
    if (parameters.is_restored()) {
        return;
    }
    // Adds the parameters of the base class
    alps::mcbase::define_parameters(parameters);
    // Adds the convenience parameters (for save/load)
    // alps::define_convenience_parameters(parameters);
    // Define ct-hyb related parameters
    parameters
        .description("hybridization expansion simulation")
        .define<bool>("cthyb.ACCURATE_COVARIANCE", false, "TODO: UNDERSTAND WHAT THIS DOES")
        .define<std::string>("cthyb.BASEPATH","", "path in hdf5 file to which results are stored")
        .define<double>("BETA", "inverse temperature")
        .define<bool>("cthyb.COMPUTE_VERTEX", false, "whether to compute the vertex functions or not.")
        .define<std::string>("cthyb.DELTA","path for hybridization function file")
        .define<bool>("cthyb.DELTA_IN_HDF5",false,"true if hybridization function file is in hdf5 format")
        .define<bool>("cthyb.DMFT_FRAMEWORK",false,"true if we need to tie into a dmft framework")
        .define<bool>("cthyb.GLOBALFLIP", false, "TODO: UNDERSTAND WHAT THIS DOES.")
        .define<double>("cthyb.J",0,"interaction value for density-density Hund's coupling term J.")
        .define<bool>("cthyb.K_IN_HDF5",false,"set to true if retarded interaction K is stored in hdf5.")
        .define<bool>("cthyb.MEASURE_freq",true, "measure in frequency domain")
        .define<bool>("cthyb.MEASURE_g2w",false, "measure two-particle Green's function in frequency space")
        .define<bool>("cthyb.MEASURE_h2w",false, "measure two-particle H Green's function in frequency space")
        .define<bool>("cthyb.MEASURE_legendre",false, "measure legendre Green's function coefficients")
        .define<bool>("cthyb.MEASURE_nn",false, "measure static density-density correlation functions")
        .define<bool>("cthyb.MEASURE_nnt",false, "measure density-density correlation functions <n(0) n(t)>")
        .define<bool>("cthyb.MEASURE_nnw",false, "measure density-density correlation functions in frequency domain")
        .define<bool>("cthyb.MEASURE_sector_statistics",false, "measure sector statistics")
        .define<bool>("cthyb.MEASURE_time",false, "measure in the time domain")
        .define<double>("MU", "chemical potential / orbital energy values") //!TODO: document the shift by U/2
        .define<std::string>("MU_VECTOR", "file name for file with chemical potential / orbital energy values")
        .define<bool>("MU_IN_HDF5", false,"true if the file MU_VECTOR points to a hdf5 file")
        .define<int >("cthyb.N_HISTOGRAM_ORDERS",200, "orders for the histograms of probability per order")
        .define<int >("cthyb.N_LEGENDRE",0,"number of legendre coefficients")
        .define<int >("NMATSUBARA",40,"number of matsubara coefficients")
        .define<int >("cthyb.N_MEAS","number of updates per measurement")
        .define<int >("FLAVORS","number of spin-orbitals (sometimes called flavors)")
        .define<int >("N","number of imaginary time discretization points")
        .define<int >("cthyb.N_W",0,"number of bosonic Matsubara frequencies for the two-particle measurement (0 ... N_W)")
        .define<int >("cthyb.N_nn",0,"number of points for the measurement of the density density correlator")
        .define<int >("cthyb.N_w2",0,"number of fermionic frequencies for the two-particle measurement (-N_w2 ... N_w2-1)")
        .define<std::string>("cthyb.RET_INT_K","file with the retarted interaction information. See doc for format.")
        .define<bool>("cthyb.SPINFLIP",false,"TODO: UNDERSTAND THIS PARAMETER")
        .define<unsigned long>("cthyb.SWEEPS","total number of Monte Carlo sweeps to be done")
        .define<bool>("cthyb.TEXT_OUTPUT","if this is enabled, we write text files in addition to hdf5 files")
        .define<unsigned long>("cthyb.THERMALIZATION","thermalization steps")
        .define<double>("U","interaction value. Only specify if you are not reading an U matrix")
        .define<double>("Uprime",0,"interaction value Uprime. Only specify if you are not reading an U matrix")
        .define<std::string>("U_MATRIX","file name for file that contains the interaction matrix")
        .define<bool>("UMATRIX_IN_HDF5",false,"true if we store the U_matrix as /Umatrix in a hdf5 file")
        .define<bool>("VERBOSE",false,"how verbose the code is. true = more output")
        .define<std::size_t>("MAX_TIME", "maximum solver runtime")
        .define<std::string>("solver.OUTFILE_H5GF", "alps_solver_in.h5gf", "H5GF Green's function input file containing G0(omega,k) at /G0 and G0(ij, tau) at /G0_tau_rs")
        .define<std::string>("solver.INFILE_H5GF", "alps_solver_out.h5gf","H5GF Green's function output file containing G(omega,k) at /G_omega and G(ij, tau) at /G_tau")
        .define<int >("L", 200, "Number of Brillouin Zone points")
        .define<double>("t", 1.0, "Hopping element: nearest neighbor")
        .define<double>("tprime", 0.0, "Hopping element: next-nearest neighbor")
  ;
}
Example #5
0
 unsigned int handle_nonopt(const parameters_type& params) {
     inputfile = *(params.current());
     return 1;
 }
Example #6
0
 unsigned int handle_behind_parameters(const parameters_type& params) {
     // only one input is allowed
     throw avslint_error(BAD_ARGUMENT,
               "Don't specify anything behind the nonopt parameter: "
             + *(params.current()) + "\n");
 }
Example #7
0
 // implementations for virtual member functions of the super class
 // util::getopt::getopt
 unsigned int handle_unknown_opt(const parameters_type& params) {
     // cash unknown options
     unknown_opt.push_back(*(params.current()));
     return 1;
 }
Example #8
0
    static inline void apply(Node & n,
                             Node & second_node,
                             Box & box1,
                             Box & box2,
                             parameters_type const& parameters,
                             Translator const& translator,
                             Allocators & allocators)
    {
        typedef typename rtree::elements_type<Node>::type elements_type;
        typedef typename elements_type::value_type element_type;
        typedef typename rtree::element_indexable_type<element_type, Translator>::type indexable_type;

        elements_type & elements1 = rtree::elements(n);
        elements_type & elements2 = rtree::elements(second_node);
        
        BOOST_GEOMETRY_INDEX_ASSERT(elements1.size() == parameters.get_max_elements() + 1, "unexpected elements number");

        // copy original elements - use in-memory storage (std::allocator)
        // TODO: move if noexcept
        typedef typename rtree::container_from_elements_type<elements_type, element_type>::type
            container_type;
        container_type elements_copy(elements1.begin(), elements1.end());                                   // MAY THROW, STRONG (alloc, copy)
        container_type elements_backup(elements1.begin(), elements1.end());                                 // MAY THROW, STRONG (alloc, copy)
        
        // calculate initial seeds
        size_t seed1 = 0;
        size_t seed2 = 0;
        quadratic::pick_seeds<Box>(elements_copy, parameters, translator, seed1, seed2);

        // prepare nodes' elements containers
        elements1.clear();
        BOOST_GEOMETRY_INDEX_ASSERT(elements2.empty(), "second node's elements container should be empty");

        BOOST_TRY
        {
            // add seeds
            elements1.push_back(elements_copy[seed1]);                                                      // MAY THROW, STRONG (copy)
            elements2.push_back(elements_copy[seed2]);                                                      // MAY THROW, STRONG (alloc, copy)

            // calculate boxes
            detail::bounds(rtree::element_indexable(elements_copy[seed1], translator), box1);
            detail::bounds(rtree::element_indexable(elements_copy[seed2], translator), box2);

            // remove seeds
            if (seed1 < seed2)
            {
                rtree::move_from_back(elements_copy, elements_copy.begin() + seed2);                        // MAY THROW, STRONG (copy)
                elements_copy.pop_back();
                rtree::move_from_back(elements_copy, elements_copy.begin() + seed1);                        // MAY THROW, STRONG (copy)
                elements_copy.pop_back();
            }
            else
            {
                rtree::move_from_back(elements_copy, elements_copy.begin() + seed1);                        // MAY THROW, STRONG (copy)
                elements_copy.pop_back();
                rtree::move_from_back(elements_copy, elements_copy.begin() + seed2);                        // MAY THROW, STRONG (copy)
                elements_copy.pop_back();
            }

            // initialize areas
            content_type content1 = index::detail::content(box1);
            content_type content2 = index::detail::content(box2);

            size_t remaining = elements_copy.size();

            // redistribute the rest of the elements
            while ( !elements_copy.empty() )
            {
                typename container_type::reverse_iterator el_it = elements_copy.rbegin();
                bool insert_into_group1 = false;

                size_t elements1_count = elements1.size();
                size_t elements2_count = elements2.size();

                // if there is small number of elements left and the number of elements in node is lesser than min_elems
                // just insert them to this node
                if ( elements1_count + remaining <= parameters.get_min_elements() )
                {
                    insert_into_group1 = true;
                }
                else if ( elements2_count + remaining <= parameters.get_min_elements() )
                {
                    insert_into_group1 = false;
                }
                // insert the best element
                else
                {
                    // find element with minimum groups areas increses differences
                    content_type content_increase1 = 0;
                    content_type content_increase2 = 0;
                    el_it = pick_next(elements_copy.rbegin(), elements_copy.rend(),
                                      box1, box2, content1, content2, translator,
                                      content_increase1, content_increase2);

                    if ( content_increase1 < content_increase2 ||
                         ( content_increase1 == content_increase2 && ( content1 < content2 ||
                           ( content1 == content2 && elements1_count <= elements2_count ) )
                         ) )
                    {
                        insert_into_group1 = true;
                    }
                    else
                    {
                        insert_into_group1 = false;
                    }
                }

                // move element to the choosen group
                element_type const& elem = *el_it;
                indexable_type const& indexable = rtree::element_indexable(elem, translator);

                if ( insert_into_group1 )
                {
                    elements1.push_back(elem);                                                              // MAY THROW, STRONG (copy)
                    geometry::expand(box1, indexable);
                    content1 = index::detail::content(box1);
                }
                else
                {
                    elements2.push_back(elem);                                                              // MAY THROW, STRONG (alloc, copy)
                    geometry::expand(box2, indexable);
                    content2 = index::detail::content(box2);
                }

                BOOST_GEOMETRY_INDEX_ASSERT(!elements_copy.empty(), "expected more elements");
                typename container_type::iterator el_it_base = el_it.base();
                rtree::move_from_back(elements_copy, --el_it_base);                                         // MAY THROW, STRONG (copy)
                elements_copy.pop_back();

                BOOST_GEOMETRY_INDEX_ASSERT(0 < remaining, "expected more remaining elements");
                --remaining;
            }
        }
        BOOST_CATCH(...)
        {
            //elements_copy.clear();
            elements1.clear();
            elements2.clear();

            rtree::destroy_elements<Value, Options, Translator, Box, Allocators>::apply(elements_backup, allocators);
            //elements_backup.clear();

            BOOST_RETHROW                                                                                     // RETHROW, BASIC
        }