delete deprecated file, fix generate annealing

This commit is contained in:
robrobo
2025-08-09 18:26:04 +02:00
parent b02fe38415
commit 93d0625ca6
2 changed files with 2 additions and 58 deletions

View File

@@ -80,7 +80,7 @@ def main():
#temps = generate_temperature_list_dynamic(args.dT, args.Tmin, args.Tmax, args.rel_tol) #temps = generate_temperature_list_dynamic(args.dT, args.Tmin, args.Tmax, args.rel_tol)
temps = generate_temperature_list(args.dT, args.Tmin, args.Tmax, args.rel_tol) temps = generate_temperature_list(args.dT, args.Tmin, args.Tmax, args.rel_tol)
if args.cooling: if not args.cooling:
temps = list(reversed(temps)) temps = list(reversed(temps))
if args.start_time > 0: if args.start_time > 0:
@@ -89,6 +89,7 @@ def main():
else: else:
times = generate_times_list(len(temps), args.start_time, args.end_time) times = generate_times_list(len(temps), args.start_time, args.end_time)
print("annealing = single")
print(f"annealing-npoints = {len(times)}") print(f"annealing-npoints = {len(times)}")
print("annealing-time = " + " ".join(f"{t:.3f}" for t in times)) print("annealing-time = " + " ".join(f"{t:.3f}" for t in times))
print("annealing-temp = " + " ".join(f"{t:.2f}" for t in temps)) print("annealing-temp = " + " ".join(f"{t:.2f}" for t in temps))

View File

@@ -1,57 +0,0 @@
#!/usr/bin/python3.12
import numpy as np
import math
def round_dynamic(x, rel_tol=1e-3, max_decimals=6, max_negative_decimals=3):
"""
Dynamically round x so that the relative error is within rel_tol.
Supports negative decimals for large values.
"""
if x == 0:
return 0.0
# Determine the required number of decimals (can be negative)
decimals = -int(math.floor(math.log10(rel_tol * abs(x))))
# Clamp within allowed range
decimals = max(-max_negative_decimals, min(max_decimals, decimals))
if decimals >= 0:
return round(x, decimals)
else:
# Round to nearest 10^(-decimals)
factor = 10 ** (-decimals)
return round(x / factor) * factor
def generate_temperature_list_dynamic(dT=10, Tmin=10, Tmax=5000, rel_tol=5e-3):
r = (300 - dT) / 300.0
temps_down = []
T = 300
while T > Tmin:
T *= r
if T < Tmin:
break
temps_down.append(T)
inv_r = 1.0 / r
temps_up = []
T = 300
while T < Tmax:
T *= inv_r
if T > Tmax:
break
temps_up.append(T)
all_T = np.array(temps_down[::-1] + [300.0] + temps_up)
# Apply dynamic rounding
rounded_T = [round_dynamic(t, rel_tol=rel_tol) for t in all_T]
rounded_T = np.unique(rounded_T)
return rounded_T
T = generate_temperature_list_dynamic(dT=30, rel_tol=5e-3)
print(len(T))
print(T)
print(np.linspace(0, 100000, len(T), endpoint=True))