Ejemplo n.º 1
0
int main(const int argc, const char** argv)
{
    if (argc < 7) {
        std::cout << "Usage: cluster NUM_PT M_MEAN M_STD R0 DT NUM_ITERS" << std::endl;
        return 1;
    }

    size_t num_pts = std::stoull(argv[1]);
    double mass_mean = std::atof(argv[2]);
    double mass_std = std::atof(argv[3]);
    double rad0 = std::atof(argv[4]);
    double timestep = std::atof(argv[5]);
    size_t num_iters = std::stoull(argv[6]);

    auto integrator = std::function<decltype(rk4)>(rk4);
    Cluster cl (num_pts, mass_mean, mass_std, rad0, integrator);

    arma::cube snapshots (num_pts, 9, num_iters);
    snapshots.slice(0) = cl.getStateMatrix();

    for (int i = 1; i < num_iters; i++) {
        cl.update(timestep);
        snapshots.slice(i) = cl.getStateMatrix();
    }

    snapshots.save("result.h5", arma::hdf5_binary);

    return 0;
}
Ejemplo n.º 2
0
void ModelManager::printSnapshots() const {
	Snapshots::const_iterator it = snapshots().begin();
	while(it != snapshots().end()){
		const Snapshot& s = it->second;
		
		printf("%s\n", it->first.c_str());
		
		Snapshot::const_iterator it2 = s.begin();
		
		while(it2 != s.end()){
			printf("\t%s = ", it2->first.c_str());
			it2->second.print();
			++it2;
		}
		
		++it;
	}
}
Ejemplo n.º 3
0
rapidjson::Value& histogram::report(rapidjson::Value &stat_value,
                                    rapidjson::Document::AllocatorType &allocator) {
	validate_snapshots();

	rapidjson::Value snapshots(rapidjson::kArrayType);
	snapshots.Reserve(m_snapshots.size(), allocator);
	for (auto it =  m_snapshots.begin(), end = m_snapshots.end(); it != end; ++it) {
		rapidjson::Value snapshot_value(rapidjson::kObjectType);
		snapshots.PushBack(print_data(snapshot_value, allocator, *it),
		                   allocator);
	}

	stat_value.AddMember("snapshots", snapshots, allocator);

	rapidjson::Value last_value(rapidjson::kObjectType);
	stat_value.AddMember("last_snapshot",
	                     print_data(last_value, allocator, m_last_data),
	                     allocator);

	clear_last();

	return stat_value;
}
Ejemplo n.º 4
0
		snapshots get_snapshots(time_range_t T, double Tabserr = 0, double Trelerr = 0)
		{
			return snapshots(*this, T, Tabserr, Trelerr);
		}