"""共同的模拟教学数据；不代表真实材料测量或物理规律。"""
from pathlib import Path
import csv
import numpy as np

OUT = Path(__file__).resolve().parent / 'outputs'
OUT.mkdir(exist_ok=True)

def materials():
    rng = np.random.default_rng(42)
    temperature = rng.uniform(300, 900, 240)
    fraction = rng.uniform(0, 1, 240)
    size = rng.uniform(10, 100, 240)
    X = np.column_stack([temperature, fraction, size])
    y = 2 + .004 * temperature + 3 * fraction**2 - .015 * size + rng.normal(0, .15, 240)
    with (OUT / 'simulated_materials.csv').open('w', newline='', encoding='utf-8') as f:
        w = csv.writer(f)
        w.writerow(['temperature_K', 'fraction', 'size_nm', 'teaching_response'])
        w.writerows(np.column_stack([X, y]))
    return X, y
