Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Evaleev/feature/wolfram orbital plotting #499

Merged
merged 7 commits into from
Sep 28, 2023
Prev Previous commit
Next Next commit
introduced print_tree_jsonfile, wrapper around Function::print_tree_j…
…son that also saves the simulation cell in JSON
evaleev committed Sep 11, 2023
commit 92d30d0526c3283a9ab24ba0d6cc51c060e2250d
24 changes: 24 additions & 0 deletions src/madness/mra/funcplot.h
Original file line number Diff line number Diff line change
@@ -990,6 +990,30 @@ void plot_plane(World& world, const std::vector<Function<double,NDIM> >& vfuncti
fclose(file);
}

template<size_t NDIM>
typename std::enable_if<NDIM==3,void>::type
print_tree_jsonfile(World& world, const Function<double,NDIM>& f, std::string filename) {

if (world.size() > 1)
return;

Tensor<double> cell = copy(FunctionDefaults<3>::get_cell());
std::ofstream os(filename.c_str());

os << "{";
os << "\"cell\":[";
for (int xyz = 0; xyz != 3; ++xyz) {
os << "[" << cell(xyz, 0) << "," << cell(xyz, 1) << "]";
if (xyz != 2)
os << ",";
}
os << "],";

os << "\"tree\":{";
f.print_tree_json(os);
os << "}}";
}

/// convenience to get plot_plane and plot_cubefile
template<size_t NDIM>
void plot(const std::vector<Function<double,NDIM> >& vf, const std::string& name, const std::vector<std::string>& header){