Some checks failed
gitea-physics/pathfinder/pipeline/pr-master There was a failure building this commit
45 lines
1.3 KiB
Python
45 lines
1.3 KiB
Python
import itertools
|
|
import logging
|
|
import multiprocessing
|
|
import numpy
|
|
import pathfinder.model.oscillating
|
|
|
|
|
|
def print_result(msg, result):
|
|
logging.info(msg)
|
|
logging.info(f"\tResult: {result.pathfinder_x}")
|
|
logging.info(f"\tSuccess: {result.success}. {result.message}")
|
|
try:
|
|
logging.info(f"\tFunc evals: {result.nfev}")
|
|
except AttributeError:
|
|
pass
|
|
try:
|
|
logging.info(f"\tJacb evals: {result.njev}")
|
|
except AttributeError:
|
|
pass
|
|
|
|
|
|
def try_initial_position(model, expected_result, initial_pos):
|
|
res = model.sol_basinhopping(initial_position=initial_pos)
|
|
logging.info(res)
|
|
return res.pathfinder_x
|
|
|
|
|
|
def main():
|
|
logging.info("Running script...")
|
|
dot_inputs = list(
|
|
(([.5, -1, 0], numpy.power(10, f))) for f in numpy.arange(1, 3, .1)
|
|
)
|
|
logging.info(dot_inputs)
|
|
dipole = pathfinder.model.oscillating.OscillatingDipole([1, 2, 3], [.51, -1.2, 0], 8)
|
|
expected_result = numpy.array([1, 2, 3, .51, -1.2, 0, 8])
|
|
dipole_arrangement = pathfinder.model.oscillating.OscillatingDipoleArrangement([dipole])
|
|
dot_measurements = dipole_arrangement.get_dot_measurements(dot_inputs)
|
|
dot_measurements_with_error = dipole_arrangement.get_dot_measurements_with_random(dot_inputs)
|
|
|
|
logging.info([(m.f, m.v) for m in dot_measurements])
|
|
logging.info([(m.f, m.v) for m in dot_measurements_with_error])
|
|
|
|
if __name__ == "__main__":
|
|
logging.basicConfig(level=logging.DEBUG)
|
|
main() |