This notebook generates input files for use with the ring_ma program.

To use it, create a "template" input file where the parameters (either one or two) that you wish to scan are replaced with the word "TARGET1" or "TARGET2" respectively. Then define the values for your scan below, and pass the template filename and the values to the MakeFiles routine.

The format for the values argument is either a 1xN list or a 2xN list, depending on how many parameters your scanning. Therefore, even if your scan is conceptually 2D, it must be flattened before passed as an argument. Examples are shown below.

If you want to make scans of multiple template files, then you can use Mathematica's Map function to thread the MakeFiles function over arrays of filenames and values. This is not recommended for the novice Mathematica user.

MakeFiles[templateFile_,flatVals_]:=(
If[Length[Dimensions[flatVals]]==1,
valString=Map[ToString[SetPrecision[#,3],CForm]&,flatVals],
valString=Map[ToString[SetPrecision[#,3],CForm]&,flatVals,{2}]];
nVals=Length[flatVals];
padSize=Log[10,nVals+1]//Ceiling;
lastPeriod=StringPosition[templateFile,"."][[-1,2]];
outFileBase=StringDrop[templateFile,{lastPeriod+1,StringLength[templateFile]}];
outFileName=Table[outFileBase<>ToString[PaddedForm[i,padSize,NumberPadding->{"0","0"},NumberSigns->{"",""}]]<>".in",{i,1,nVals}];
file=Import[templateFile,"Lines"];
For[i=1, i≤nVals,i++,
Export[outFileName[[i]],
If[Length[Dimensions[flatVals]]==1,
Map[StringReplace[#,"TARGET1"->valString[[i]]]&,file],
Map[StringReplace[#,{"TARGET1"->valString[[i,1]],"TARGET2"->valString[[i,2]]}]&,file]],
"Lines"]
])

SetDirectory["PUT YOUR WORKING DIRECTORY HERE"]
FlatTab2D=Flatten[Table[{10^x,y},{x,-10,10},{y,1,10}],1];
FlatTab1D=Table[1,{x,1,25}];

MakeFiles["TEMPLATE FILE",FlatTab1D]