Skip to content

ATaylorAerospace/Thermal-Agent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

59 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

thermalagent

๐Ÿ›ธ Deep-Space Photonics Thermal Advisor

CI Python 3.10+ AWS Bedrock HuggingFace Dataset โ€” 40K rows Streamlit XGBoost License: CC BY 4.0 Contact A Taylor

Fine tuned LLM on AWS Bedrock + physics simulator for recommending thermal mitigation strategies in deep space photonic instruments

Physics simulation ยท Bedrock fine tuning ยท XGBoost classification ยท Streamlit demo


๐Ÿ’ก The Problem

Photonic Integrated Circuits (PICs) are the backbone of next generation space probe instruments that operate in deep space โ€” spectrometers, laser communication terminals, waveguide sensor arrays, and photonic signal processors. But space is brutal:

  • ๐ŸŒก๏ธ Spectral drift โ€” temperature swings shift refractive indices, pushing resonant wavelengths off-target and corrupting measurements
  • ๐Ÿ“ Waveguide misalignment โ€” differential thermal expansion between chip layers destroys optical coupling, killing signal throughput
  • ๐Ÿ’ฅ Mechanical cracking โ€” repeated thermal cycling fatigues bonding interfaces and dielectric layers until catastrophic failure

A spectrometer on a Jovian probe faces 180 K temperature swings. An optical link in the outer solar system endures 240 K. The wrong mitigation strategy means mission failure.


โœจ The Solution

This project combines deterministic physics with AI-driven recommendations to prescribe optimal thermal mitigation strategies for any instrument-material-environment combination:

Layer What It Does Status
๐Ÿ”ฌ Physics Simulator Computes ฮ”n and strain from first principles โœ… Live
๐Ÿค– Bedrock Fine-Tuned LLM Generates detailed strategy recommendations trained on 40K scenarios โœ… Live
๐Ÿ“Š XGBoost Classifier Fast Passive / Active / Hybrid prediction with calibrated probabilities โœ… Live
๐Ÿ–ฅ๏ธ Streamlit App Interactive two-mode demo (physics + AI advisor) โœ… Live
๐Ÿงช CI Pipeline Automated pytest across Python 3.10โ€“3.12 on every push and PR โœ… Live

๐Ÿ—๏ธ Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚              Streamlit Interactive App               โ”‚
โ”‚         (Physics Simulator  ยท  AI Advisor)          โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚   ThermalDriftSim    โ”‚    BedrockInferenceClient    โ”‚
โ”‚   ฮ”n = dn/dT ร— ฮ”T   โ”‚    Fine-tuned Titan Express  โ”‚
โ”‚   ฮต  = ฮฑ ร— ฮ”T       โ”‚    + streaming responses      โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚  XGBoost Classifier  โ”‚    DataPrepPipeline          โ”‚
โ”‚  P(Passive|Active|   โ”‚    HuggingFace โ†’ JSONL โ†’ S3  โ”‚
โ”‚    Hybrid)           โ”‚                               โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚           AWS Bedrock  ยท  S3  ยท  IAM                โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿ“ฆ Dataset

40,000 synthetic thermal scenarios โ€” Taylor658/deep-space-optical-chip-thermal-dataset

Chip Materials

Material dn/dT (Kโปยน) ฮฑ โ€” Thermal Expansion (Kโปยน) Sensitivity
Silicon 1.86 ร— 10โปโด 2.6 ร— 10โปโถ High
Silicon Nitride 2.45 ร— 10โปโต 8.0 ร— 10โปโท Low
Polymer 1.1 ร— 10โปโด 2.2 ร— 10โปโถ Moderate
Indium Phosphide 3.4 ร— 10โปโด 4.6 ร— 10โปโถ Very High

Environments

Environment Expected ฮ”T (K) Severity
Near Earth Deep Space 120 โš ๏ธ Moderate
Mars Transit 150 โš ๏ธ Moderate
Jovian System 180 ๐Ÿ”ด High
Outer Solar System 240 ๐Ÿ”ด Critical

Coverage

  • 4 instruments โ€” Spectrometer, Laser Communication Terminal, Waveguide Sensor Array, Photonic Signal Processor
  • 3 strategy types โ€” Passive, Active, Hybrid

๐Ÿš€ Quick Start

# Clone
git clone https://github.com/ATaylorAerospace/Thermal-Agent.git
cd Thermal-Agent

# Install
pip install -r requirements.txt

# Configure
cp .env.example .env
# โ†’ Edit .env with your AWS credentials and S3 bucket

# Prepare dataset & upload to S3
python src/data_prep.py --output_dir data/ --upload_to_s3

# Launch fine-tuning job
python src/bedrock_finetune.py --config config/bedrock_config.yaml --action start

# Run the interactive app
streamlit run app/streamlit_app.py

๐Ÿ”ฎ Usage Examples

1. Physics Simulation โ€” Compute Thermal Risk

from src.simulator import ThermalDriftSimulator

sim = ThermalDriftSimulator()

# Evaluate Indium Phosphide on a Jovian mission
result = sim.evaluate("Indium Phosphide", "Jovian System")

print(f"ฮ”n = {result['delta_n']:.6f}")       # ฮ”n = 0.061200
print(f"Strain = {result['strain']:.2e}")     # Strain = 8.28e-04
print(f"Risk: {result['risk']}")              # Risk: Critical
print(f"Strategy: {result['recommended_strategy_hint']}")  # Strategy: Hybrid

2. Compare All Materials for a Given Environment

from src.simulator import ThermalDriftSimulator

sim = ThermalDriftSimulator()

for material in sim.get_all_materials():
    r = sim.evaluate(material, "Outer Solar System")
    print(f"{material:20s}  ฮ”n={r['delta_n']:.6f}  ฮต={r['strain']:.2e}  โ†’ {r['risk']}")
Silicon               ฮ”n=0.044640  ฮต=6.24e-04  โ†’ Critical
Silicon Nitride       ฮ”n=0.005880  ฮต=1.92e-04  โ†’ Moderate
Polymer               ฮ”n=0.026400  ฮต=5.28e-04  โ†’ Critical
Indium Phosphide      ฮ”n=0.081600  ฮต=1.10e-03  โ†’ Critical

3. XGBoost Strategy Prediction

from src.strategy_classifier import StrategyClassifier

clf = StrategyClassifier()
clf.load("results/strategy_classifier.pkl")

# Predict with calibrated probabilities
proba = clf.predict_proba(
    material="Silicon",
    instrument="Spectrometer",
    environment="Mars Transit",
    thermal_effect="Spectral Drift",
)
print(proba)
# {'Active': 0.12, 'Hybrid': 0.61, 'Passive': 0.27}

4. Bedrock Inference โ€” AI Thermal Advisor

from src.inference import BedrockInferenceClient

client = BedrockInferenceClient(model_id="your-fine-tuned-model-arn")

prompt = client.build_thermal_prompt(
    instrument="Laser Communication Terminal",
    material="Indium Phosphide",
    environment="Outer Solar System",
    thermal_effect="Waveguide Misalignment",
)

# Stream the response
for token in client.stream_invoke(prompt):
    print(token, end="", flush=True)

5. Run the Full Pipeline

# One command โ€” prepare data, launch fine-tuning, poll until complete
bash scripts/run_pipeline.sh

๐Ÿ“ Repository Structure

Thermal-Agent/
โ”œโ”€โ”€ .github/
โ”‚   โ””โ”€โ”€ workflows/
โ”‚       โ””โ”€โ”€ ci.yml                   # GitHub Actions CI โ€” pytest on 3.10โ€“3.12
โ”œโ”€โ”€ app/
โ”‚   โ””โ”€โ”€ streamlit_app.py             # Interactive two-tab demo
โ”œโ”€โ”€ config/
โ”‚   โ””โ”€โ”€ bedrock_config.yaml          # Bedrock hyperparameters & S3 paths
โ”œโ”€โ”€ docs/
โ”‚   โ””โ”€โ”€ thermals.png                 # Hero banner image
โ”œโ”€โ”€ notebooks/
โ”‚   โ”œโ”€โ”€ 01_eda.ipynb                 # Exploratory data analysis
โ”‚   โ””โ”€โ”€ 02_bedrock_fine_tuning.ipynb # End-to-end fine-tuning walkthrough
โ”œโ”€โ”€ results/                         # Model artifacts & evaluation outputs
โ”œโ”€โ”€ scripts/
โ”‚   โ””โ”€โ”€ run_pipeline.sh              # Full pipeline runner
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ __init__.py                  # Public API exports
โ”‚   โ”œโ”€โ”€ bedrock_finetune.py          # Bedrock job lifecycle manager
โ”‚   โ”œโ”€โ”€ data_prep.py                 # HuggingFace โ†’ Bedrock JSONL โ†’ S3
โ”‚   โ”œโ”€โ”€ inference.py                 # Base + fine-tuned model inference
โ”‚   โ”œโ”€โ”€ simulator.py                 # Physics-based thermal drift engine
โ”‚   โ””โ”€โ”€ strategy_classifier.py       # XGBoost Passive/Active/Hybrid
โ”œโ”€โ”€ tests/
โ”‚   โ”œโ”€โ”€ __init__.py                  # Test package init
โ”‚   โ”œโ”€โ”€ test_classifier.py           # Classifier tests
โ”‚   โ””โ”€โ”€ test_simulator.py            # Physics simulator tests
โ”œโ”€โ”€ .env.example                     # AWS credential template
โ”œโ”€โ”€ .gitignore
โ”œโ”€โ”€ conftest.py                      # Pytest path configuration
โ”œโ”€โ”€ CONTRIBUTING.md                  # Development setup & PR guidelines
โ”œโ”€โ”€ README.md
โ””โ”€โ”€ requirements.txt

๐Ÿงฉ Components

๐Ÿ”ฌ Physics Simulator (src/simulator.py)

Computes refractive index shift (ฮ”n = dn/dT ร— ฮ”T) and mechanical strain (ฮต = ฮฑ ร— ฮ”T) for any material-environment pair. Classifies risk as Low โ†’ Moderate โ†’ High โ†’ Critical and maps to a strategy hint. Fully type-annotated for IDE support.

๐Ÿ“‹ Data Preparation (src/data_prep.py)

Loads the HuggingFace dataset, converts to Bedrock-compatible {"prompt": ..., "completion": ...} JSONL, performs stratified train/validation splitting, and uploads to S3.

โš™๏ธ Bedrock Fine-Tune Manager (src/bedrock_finetune.py)

Full lifecycle management โ€” start, monitor, cancel, and list fine-tuning jobs on Amazon Titan Text Express.

๐Ÿค– Inference Client (src/inference.py)

Synchronous and streaming inference against base and fine-tuned Bedrock models. Both invoke() and stream_invoke() accept configurable max_tokens and temperature parameters. Includes a structured prompt builder matching the training format and a side-by-side model comparison utility.

๐Ÿ“Š Strategy Classifier (src/strategy_classifier.py)

XGBoost classifier predicting Passive / Active / Hybrid strategies with calibrated probability estimates. Includes fitted-state validation to prevent silent failures. Fast fallback when Bedrock is unavailable.


๐Ÿงช Testing

Tests run automatically via GitHub Actions CI on every push and pull request against Python 3.10, 3.11, and 3.12.

# Run all tests locally
pytest tests/ -v

# Run simulator tests only
pytest tests/test_simulator.py -v

# Run classifier tests only
pytest tests/test_classifier.py -v

๐Ÿค Contributing

See CONTRIBUTING.md for development setup, testing instructions, and pull request guidelines.


๐Ÿ“œ License

This work is licensed under CC BY 4.0.

Copyright (c) 2026 A Taylor


๐Ÿ“ฌ Contact

Have questions, ideas, or want to collaborate? Reach out directly:

Contact A Taylor

About

Physics simulator and fine tuned LLM for predicting thermal drift in deep space photonic instruments and recommending mitigation strategies across material and environment combinations. Built on AWS Bedrock, trained on 40K synthetic scenarios

Topics

Resources

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors