THE TRASH ONE -> LUNIT_TEST_A

import os import shutil import zipfile import json from datetime import datetime import numpy as np import pandas as pd # Environment Detection try: from google.colab import files, drive IN_COLAB = True except ImportError: IN_COLAB = False # Configuration & Paths PROJECT_NAME = "LUNIT_TEST_A_CORRECTED" TIMESTAMP = datetime.now().strftime("%Y%m%d_%H%M%S") OUTPUT_DIR = f"output_{TIMESTAMP}" ZIP_NAME = f"{PROJECT_NAME}_{TIMESTAMP}.zip" DRIVE_BASE_DIR = f"/content/drive/MyDrive/{PROJECT_NAME}" DRIVE_TARGET_DIR = os.path.join(DRIVE_BASE_DIR, OUTPUT_DIR) # Physical Constants PHI = (1.0 + np.sqrt(5.0)) / 2.0 A1_COEFF = 1.0 + (1.0 / (PHI**2)) # The corrected 1.381966... A2_TARGET = 1.0 / (PHI**3) # The 0.236067... asymptote def run_test_a_isolated(): # STEP 1 — SAVE TO COLAB WORKSPACE os.makedirs(OUTPUT_DIR, exist_ok=True) # Sweep ends at 1e-5. Beyond 1e-6, exact_resid - linear_pred approaches ~1e-16, # which is the float64 machine epsilon, breaking the clean ratio calculation. eta_levels = [1e-1, 1e-2, 1e-3, 1e-4, 1e-5] results = [] for eta in eta_levels: x_val = PHI + eta L_x = x_val - (1.0 / x_val) exact_resid = L_x - 1.0 linear_pred = A1_COEFF * eta delta = exact_resid - linear_pred # Test A specific diagnostic ratio ratio = np.abs(delta) / (eta**2) results.append({ "eta": eta, "L_x": L_x, "exact_resid": exact_resid, "linear_pred": linear_pred, "delta": delta, "ratio_abs_delta_over_eta_sq": ratio }) df = pd.DataFrame(results) csv_path = os.path.join(OUTPUT_DIR, "test_a_convergence.csv") df.to_csv(csv_path, index=False) # Store explicit diagnostic metric final_ratio = float(df['ratio_abs_delta_over_eta_sq'].iloc[-1]) metrics = { "applied_linear_coefficient": A1_COEFF, "target_quadratic_asymptote": A2_TARGET, "observed_final_ratio": final_ratio, "asymptote_error": abs(final_ratio - A2_TARGET), "timestamp": TIMESTAMP } json_path = os.path.join(OUTPUT_DIR, "test_a_metrics.json") with open(json_path, 'w') as f: json.dump(metrics, f, indent=4) # STEP 2 — CREATE MASTER ZIP master_zip_path = ZIP_NAME with zipfile.ZipFile(master_zip_path, 'w', zipfile.ZIP_DEFLATED) as zipf: for root, _, files_list in os.walk(OUTPUT_DIR): for file in files_list: file_path = os.path.join(root, file) arcname = os.path.relpath(file_path, OUTPUT_DIR) zipf.write(file_path, arcname) # STEP 3 — BACKUP TO GOOGLE DRIVE drive_backup_saved = False if IN_COLAB: try: drive.mount('/content/drive', force_remount=False) os.makedirs(DRIVE_TARGET_DIR, exist_ok=True) for item in os.listdir(OUTPUT_DIR): s_item = os.path.join(OUTPUT_DIR, item) d_item = os.path.join(DRIVE_TARGET_DIR, item) if os.path.isdir(s_item): shutil.copytree(s_item, d_item, dirs_exist_ok=True) else: shutil.copy2(s_item, d_item) shutil.copy2(master_zip_path, os.path.join(DRIVE_BASE_DIR, ZIP_NAME)) drive_backup_saved = True except Exception as e: print(f"Google Drive Backup Failure: {e}") # STEP 4 — DOWNLOAD TO LOCAL MACHINE download_triggered = False if IN_COLAB: try: files.download(master_zip_path) download_triggered = True except Exception as e: print(f"Download Trigger Failure: {e}") # STEP 5 — VERIFY FILES EXIST workspace_saved = os.path.exists(OUTPUT_DIR) and len(os.listdir(OUTPUT_DIR)) > 0 zip_created = os.path.exists(master_zip_path) and os.path.getsize(master_zip_path) > 0 if IN_COLAB: drive_verified = drive_backup_saved and os.path.exists(DRIVE_TARGET_DIR) else: drive_verified = True if workspace_saved: print("✓ Colab workspace saved") if drive_verified: print("✓ Google Drive backup saved" if IN_COLAB else "✓ Local execution - Drive backup N/A") if zip_created: print("✓ Download package created") # STEP 6 — FINAL STATUS REPORT file_count = sum([len(f) for _, _, f in os.walk(OUTPUT_DIR)]) archive_size_bytes = os.path.getsize(master_zip_path) if zip_created else 0 all_backups_exist = workspace_saved and zip_created and drive_verified status_str = "SUCCESS ONLY IF ALL BACKUPS EXIST" if all_backups_exist else "FAILED - PARTIAL PRESERVATION" print("\n" + "="*60) print(f"OUTPUT DIRECTORY: {os.path.abspath(OUTPUT_DIR)}") print(f"GOOGLE DRIVE BACKUP: {DRIVE_TARGET_DIR if IN_COLAB else 'N/A (Local Mode)'}") print(f"MASTER ZIP: {os.path.abspath(master_zip_path)}") print(f"FILE COUNT: {file_count}") print(f"ARCHIVE SIZE: {archive_size_bytes} bytes") print(f"STATUS: {status_str}") print("="*60) if __name__ == "__main__": run_test_a_isolated()

Popular posts from this blog

THE GOLDEN BALLROOM/BUNKER

Conceptual Summary #2: (∂t2​S−c2∇2S+βS3)=σ(x,t)⋅FR​(C[Ψ])

ICE PROUDLY ANNOUNCES NEW “ELITE” TASK FORCE COMMANDER JEREMY DEWITTE