API documentation
POST
- URL: https://sampler-flask.herokuapp.com/find-points (this page)
- Inputs: A dictionary with these possible entries
- input_file: constraints file (.txt)
- output_file: output file name
- Optional: If not supplied, _out will be added to the input file name.
For example, from input metal.txt, output will be metal_out.txt.
- Optional: If not supplied, _out will be added to the input file name.
- n_results: the number of solutions (points) to find
- Optional: If not supplied, will be 10.
- output_types: the output types to return, as a comma-delimited string
- Optional: If not supplied, will be cf = component fraction.
- types:
-
cf
- component fraction. Default. The fraction of the total for each component, for example 0.1 for a component means 10% of the total is that component. This is the basis the constraints file is in.
- The following output type(s) require a chemical formula for each component in constraints file.
- cwtf: component weight fraction. The weight fraction of the total for each component, for example 0.1 for a component means 10% of the total weight is that component. So a heavier component will have a cwtf greater than its cf.
- Output: Results file name and contents (valid points)
-
Separators
- After a file name or the last point in that file: ***
- After each point in a file: a linebreak \n
-
The number of entries in each point is:
- For cf: The number of dimensions given in the input (constraints) file.
- For cwtf: The number of dimensions, or one more if a balance of fomulation component (BOFC) is supplied in constraints file. To have the extra entry, a chemical formula must be supplied for each dimension, plus one more for the BOFC.
-
Separators
Examples
The values of entries in points may differ because Sampler uses random numbers. The number of entries will always be as below.- Input file, output file name, number of results, and output types supplied
- Inputs: {'input_file': 'mixture_with_formulas.txt', 'output_file': 'mixture_with_formulas_out.txt', 'n_results': 4, 'output_types': 'cf, cwtf'}
- Output: For each output type, results file name and 4 points
-
mixture_with_formulas_out.txt***0.000000 0.000000
1.000000 0.000000
0.000000 1.000000
0.092014 0.348421
***mixture_with_formulas_out_cwtf.txt***0.000000 0.000000 1.000000
1.000000 0.000000 0.000000
0.000000 1.000000 0.000000
0.042943 0.289223 0.667834
-
mixture_with_formulas_out.txt***0.000000 0.000000
- Input file, output file name, and number of results supplied
- Inputs: {'input_file': 'mixture_with_formulas.txt', 'output_file': 'mixture_with_formulas_out.txt', 'n_results': 4}
- Output: Results file name and 4 points
-
mixture_with_formulas_out.txt***0.000000 0.000000
1.000000 0.000000
0.000000 1.000000
0.085799 0.010204
-
mixture_with_formulas_out.txt***0.000000 0.000000
- Input file and output file name supplied
- Inputs: {'input_file': 'mixture_with_formulas.txt', 'output_file': 'mixture_with_formulas_out.txt'}
- Output: Results file name and 10 points
-
mixture_with_formulas_out.txt***0.000000 0.000000
0.500000 0.000000
1.000000 0.000000
0.000000 0.500000
0.500000 0.500000
0.000000 1.000000
0.078311 0.450474
0.489759 0.447691
0.432025 0.203087
0.774143 0.215323
-
mixture_with_formulas_out.txt***0.000000 0.000000
- Input file and output types supplied
- Inputs: {'input_file': 'mixture_with_formulas.txt', 'output_types': 'cf, cwtf'}
- Output: For each output type, results file name and 4 points
-
mixture_with_formulas_out_cwtf.txt***0.000000 0.000000 1.000000
0.281115 0.000000 0.718885
1.000000 0.000000 0.000000
0.000000 0.410211 0.589789
0.359890 0.640110 0.000000
0.000000 1.000000 0.000000
0.041414 0.342994 0.615592
0.460448 0.107272 0.432280
0.301177 0.635857 0.062965
0.142002 0.688742 0.169256
-
mixture_with_formulas_out_cwtf.txt***0.000000 0.000000 1.000000
- Input file and number of results supplied
- Inputs: {'input_file': 'mixture_with_formulas.txt', 'n_results': 4}
- Output: Results file name containing 4 points
-
mixture_with_formulas_out.txt***0.000000 0.000000
1.000000 0.000000
0.000000 1.000000
0.008202 0.311725
- Input file supplied
- Inputs: {'input_file': 'mixture_with_formulas.txt'}
- Output: Results file name and 10 points
-
mixture_with_formulas_out.txt***0.000000 0.000000
0.500000 0.000000
1.000000 0.000000
0.000000 0.500000
0.500000 0.500000
0.000000 1.000000
0.620417 0.073799
0.431811 0.383679
0.086526 0.523181
0.546799 0.233899
Python code to POST to Sampler
Because Sampler takes files as inputs, and JavaScript cannot access the filesystem, Python is recommended instead. You can use the following code.