1
0
Fork 0
mirror of https://github.com/gwm17/catima.git synced 2024-11-22 18:28:51 -05:00
This commit is contained in:
hrocho 2019-05-15 17:12:06 +02:00
parent 519081ca43
commit 6e8a41ea87

View File

@ -18,24 +18,29 @@ void catima_info(){
printf("max energy point = 10^%lf MeV/u\n",logEmax); printf("max energy point = 10^%lf MeV/u\n",logEmax);
} }
std::string material_to_string(const Material &r){
std::string s;
auto n = r.ncomponents();
for(int i = 0; i < n; i++){
auto el = r.get_element(i);
s += "#"+std::to_string(i);
s += ": A = "+std::to_string(el.A) + ", Z = "+std::to_string(el.A)+ ", stn = "+std::to_string(el.stn)+"\n";
}
return s;
};
py::list storage_info(){ py::list storage_info(){
py::list res; py::list res;
for(int i=0; i<max_storage_data;i++){ for(int i=0; i<max_storage_data;i++){
auto& data = _storage.Get(i); auto& data = _storage.Get(i);
if(data.p.A>0 && data.p.Z && data.m.ncomponents()>0){ if(data.p.A>0 && data.p.Z && data.m.ncomponents()>0){
py::list mat; py::list mat;
for(int j=0; j<data.m.ncomponents();j++){
auto e = data.m.get_element(j);
mat.append(e.A);
mat.append(e.Z);
mat.append(e.stn);
}
py::dict d; py::dict d;
py::list p; py::list p;
p.append(data.p.A); p.append(data.p.A);
p.append(data.p.Z); p.append(data.p.Z);
d["projectile"] = p; d["projectile"] = p;
d["matter"] = mat; d["matter"] = material_to_string(data.m);
d["config"] = py::cast(data.config); d["config"] = py::cast(data.config);
res.append(d); res.append(d);
} }
@ -130,16 +135,7 @@ PYBIND11_MODULE(pycatima,m){
.def("thickness_cm",&Material::thickness_cm,"set thickness in cm unit") .def("thickness_cm",&Material::thickness_cm,"set thickness in cm unit")
.def("I",py::overload_cast<>(&Material::I, py::const_), "get I") .def("I",py::overload_cast<>(&Material::I, py::const_), "get I")
.def("I",py::overload_cast<double>(&Material::I), "set I") .def("I",py::overload_cast<double>(&Material::I), "set I")
.def("__str__",[](const Material &r){ .def("__str__",&material_to_string);
std::string s;
auto n = r.ncomponents();
for(int i = 0; i < n; i++){
auto el = r.get_element(i);
s += "#"+std::to_string(i);
s += ": A = "+std::to_string(el.A) + ", Z = "+std::to_string(el.A)+ ", stn = "+std::to_string(el.stn)+"\n";
}
return s;
});
py::class_<Layers>(m,"Layers") py::class_<Layers>(m,"Layers")
.def(py::init<>(),"constructor") .def(py::init<>(),"constructor")