improved the nonlocal field dump, by allowing a custom range.

This commit is contained in:
suter_a 2023-11-08 12:57:16 +01:00
parent 3c2b0322c0
commit ecd9e4a953

View File

@ -52,6 +52,7 @@ void dnlf_syntax()
std::cout << "usage: dump_nonlocal_field [<msr-file> --out <field-dump> [--step <stepVal>] | --version | --help]" << std::endl; std::cout << "usage: dump_nonlocal_field [<msr-file> --out <field-dump> [--step <stepVal>] | --version | --help]" << std::endl;
std::cout << " <msr-file> : nonlocal msr-file name." << std::endl; std::cout << " <msr-file> : nonlocal msr-file name." << std::endl;
std::cout << " --out <field-dump> : ascii field dump output file name." << std::endl; std::cout << " --out <field-dump> : ascii field dump output file name." << std::endl;
std::cout << " --range <rangeVal> : this optional parameter (in nm) will overwrite the standard z-range = 5 * lambdaL." << std::endl;
std::cout << " --step <stepVal> : this optional parameters allows to define the z-value step size in (nm)." << std::endl; std::cout << " --step <stepVal> : this optional parameters allows to define the z-value step size in (nm)." << std::endl;
std::cout << " --version : dumps the version" << std::endl; std::cout << " --version : dumps the version" << std::endl;
std::cout << " --help : will dump this help" << std::endl; std::cout << " --help : will dump this help" << std::endl;
@ -184,7 +185,8 @@ int main(int argc, char* argv[])
{ {
std::string msrFileName(""); std::string msrFileName("");
std::string outFileName(""); std::string outFileName("");
double step(0.0); double step{0.0};
double range{0.0};
bool show_syntax(false); bool show_syntax(false);
if (argc == 1) { if (argc == 1) {
@ -214,6 +216,22 @@ int main(int argc, char* argv[])
show_syntax = true; show_syntax = true;
break; break;
} }
} else if (!strcmp(argv[i], "--range")) {
if (i < argc-1) {
try {
range = std::stod(argv[i+1]);
}
catch(std::exception& e) {
std::cout << "dump_nonlocal_field: **ERROR** <rangeVal> '" << argv[i+1] << "' seems not to be a double." << std::endl;
show_syntax = true;
break;
}
i++;
} else {
std::cerr << std::endl << "dump_nonlocal_field: **ERROR** found option --range without <rangeVal>" << std::endl;
show_syntax = true;
break;
}
} else if (!strcmp(argv[i], "--step")) { } else if (!strcmp(argv[i], "--step")) {
if (i < argc-1) { if (i < argc-1) {
try { try {
@ -269,13 +287,15 @@ int main(int argc, char* argv[])
bool done(false); bool done(false);
double deadLayer = param[8]; double deadLayer = param[8];
double b0 = param[6]; double b0 = param[6];
if (range == 0.0)
range = 5.0*param[5]; // 5*lambda
do { do {
if (z < deadLayer) { if (z < deadLayer) {
fout << z << ", " << b0 << std::endl; fout << z << ", " << b0 << std::endl;
} else { } else {
field = pip.GetMagneticField(z-deadLayer); field = pip.GetMagneticField(z-deadLayer);
fout << z << ", " << b0*field << std::endl; fout << z << ", " << b0*field << std::endl;
if (fabs(prevField-field) < 1.0e-10) if ((fabs(prevField-field) < 1.0e-10) && (z >= range))
done = true; done = true;
prevField = field; prevField = field;
} }