improved the nonlocal field dump, by allowing a custom range.
This commit is contained in:
parent
3c2b0322c0
commit
ecd9e4a953
@ -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 << " <msr-file> : nonlocal msr-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 << " --version : dumps the version" << 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 outFileName("");
|
||||
double step(0.0);
|
||||
double step{0.0};
|
||||
double range{0.0};
|
||||
bool show_syntax(false);
|
||||
|
||||
if (argc == 1) {
|
||||
@ -214,6 +216,22 @@ int main(int argc, char* argv[])
|
||||
show_syntax = true;
|
||||
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")) {
|
||||
if (i < argc-1) {
|
||||
try {
|
||||
@ -269,13 +287,15 @@ int main(int argc, char* argv[])
|
||||
bool done(false);
|
||||
double deadLayer = param[8];
|
||||
double b0 = param[6];
|
||||
if (range == 0.0)
|
||||
range = 5.0*param[5]; // 5*lambda
|
||||
do {
|
||||
if (z < deadLayer) {
|
||||
fout << z << ", " << b0 << std::endl;
|
||||
} else {
|
||||
field = pip.GetMagneticField(z-deadLayer);
|
||||
fout << z << ", " << b0*field << std::endl;
|
||||
if (fabs(prevField-field) < 1.0e-10)
|
||||
if ((fabs(prevField-field) < 1.0e-10) && (z >= range))
|
||||
done = true;
|
||||
prevField = field;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user