Build a quantum materials phase diagram mapping: temperature/field sweeps, transport,…
- User
Build a quantum materials phase diagram mapping: temperature/field sweeps, transport, and scanning probes.
Assistant
Build a quantum materials phase diagram mapping: temperature/field sweeps, transport, and scanning probes.
The user wants me to create a comprehensive visualization for quantum materials phase diagram mapping. This is a sophisticated scientific visualization that should include:
Key physical concepts to incorporate:
Design approach:
Technical implementation:
Let me create a sophisticated single-page application with:
I'll use a dark scientific theme with high contrast and professional color schemes typical of scientific instrumentation software. This is a sophisticated scientific visualization project! I'll create an interactive quantum materials phase diagram mapper with multiple measurement modalities, realistic physics simulations, and a professional scientific instrument aesthetic.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Quantum Materials Phase Diagram Mapper</title>
<script src="https://cdn.tailwindcss.com"></script>
<link href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@300;400;500;600&family=Space+Grotesk:wght@300;400;500;600;700&display=swap" rel="stylesheet">
<style>
:root {
--bg-primary: #0a0e14;
--bg-secondary: #111820;
--bg-tertiary: #1a222d;
--accent-cyan: #00d4aa;
--accent-orange: #ff6b35;
--accent-blue: #3b82f6;
--accent-purple: #a855f7;
--accent-yellow: #eab308;
--text-primary: #e8eaed;
--text-secondary: #8b949e;
--border-color: #2d3748;
--glow-cyan: rgba(0, 212, 170, 0.3);
}
* {
box-sizing: border-box;
}
body {
font-family: 'Space Grotesk', sans-serif;
background: var(--bg-primary);
color: var(--text-primary);
margin: 0;
overflow-x: hidden;
}
.mono {
font-family: 'JetBrains Mono', monospace;
}
.glass-panel {
background: linear-gradient(135deg, rgba(26, 34, 45, 0.9), rgba(17, 24, 32, 0.95));
border: 1px solid var(--border-color);
border-radius: 8px;
backdrop-filter: blur(10px);
}
.glow-border {
box-shadow: 0 0 20px rgba(0, 212, 170, 0.1), inset 0 1px 0 rgba(255,255,255,0.05);
}
.phase-label {
font-size: 10px;
letter-spacing: 0.5px;
text-transform: uppercase;
}
canvas {
display: block;
}
.slider-container input[type="range"] {
-webkit-appearance: none;
appearance: none;
width: 100%;
height: 4px;
background: var(--bg-tertiary);
border-radius: 2px;
outline: none;
}
.slider-container input[type="range"]::-webkit-slider-thumb {
-webkit-appearance: none;
appearance: none;
width: 14px;
height: 14px;
background: var(--accent-cyan);
border-radius: 50%;
cursor: pointer;
transition: transform 0.2s;
}
.slider-container input[type="range"]::-webkit-slider-thumb:hover {
transform: scale(1.2);
}
.status-dot {
width: 8px;
height: 8px;
border-radius: 50%;
animation: pulse 2s infinite;
}
@keyframes pulse {
0%, 100% { opacity: 1; }
50% { opacity: 0.5; }
}
@keyframes scanline {
0% { transform: translateY(-100%); }
100% { transform: translateY(100%); }
}
.scanline {
position: absolute;
width: 100%;
height: 2px;
background: linear-gradient(90deg, transparent, var(--accent-cyan), transparent);
animation: scanline 3s linear infinite;
opacity: 0.5;
}
@media (prefers-reduced-motion: reduce) {
.scanline, .status-dot {
animation: none;
}
}
.btn-control {
transition: all 0.2s ease;
}
.btn-control:hover {
transform: translateY(-1px);
box-shadow: 0 4px 12px rgba(0, 212, 170, 0.2);
}
.btn-control:active {
transform: translateY(0);
}
</style>
</head>
<body class="min-h-screen">
<!-- Header -->
<header class="border-b border-[#2d3748] bg-[#111820]/80 backdrop-blur-sm sticky top-0 z-50">
<div class="max-w-[1600px] mx-auto px-4 py-3 flex items-center justify-between">
<div class="flex items-center gap-4">
<div class="w-10 h-10 rounded-lg bg-gradient-to-br from-[#00d4aa] to-[#3b82f6] flex items-center justify-center">
<svg class="w-6 h-6 text-white" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z"/>
</svg>
</div>
<div>
<h1 class="text-lg font-semibold tracking-tight">Quantum Phase Mapper</h1>
<p class="text-xs text-[#8b949e] mono">QMAT-7.2 Simulation Environment</p>
</div>
</div>
<div class="flex items-center gap-6">
<div class="flex items-center gap-2">
<div class="status-dot bg-[#00d4aa]"></div>
<span class="text-xs mono text-[#8b949e]">SYSTEM READY</span>
</div>
<div class="mono text-sm text-[#8b949e]" id="clock">00:00:00</div>
</div>
</div>
</header>
<!-- Main Content -->
<main class="max-w-[1600px] mx-auto p-4 grid grid-cols-12 gap-4">
<!-- Left Panel: Phase Diagram -->
<section class="col-span-12 lg:col-span-5 glass-panel glow-border p-4">
<div class="flex items-center justify-between mb-4">
<h2 class="font-medium text-sm uppercase tracking-wider text-[#8b949e]">Phase Diagram</h2>
<div class="flex gap-2">
<button id="btn-TSweep" class="btn-control px-3 py-1.5 text-xs mono bg-[#1a222d] border border-[#2d3748] rounded hover:border-[#00d4aa] hover:text-[#00d4aa]">T-Sweep</button>
<button id="btn-HSweep" class="btn-control px-3 py-1.5 text-xs mono bg-[#1a222d] border border-[#2d3748] rounded hover:border-[#00d4aa] hover:text-[#00d4aa]">H-Sweep</button>
</div>
</div>
<div class="relative bg-[#0a0e14] rounded-lg overflow-hidden" style="aspect-ratio: 1;">
<canvas id="phaseCanvas" class="w-full h-full"></canvas>
<div class="scanline"></div>
<div class="absolute bottom-2 left-2 right-2 flex justify-between text-[10px] mono text-[#8b949e]">
<span>H (Tesla)</span>
<span>T (Kelvin)</span>
</div>
</div>
<!-- Phase Legend -->
<div class="mt-4 grid grid-cols-4 gap-2 text-center">
<div class="flex items-center gap-2 justify-center">
<div class="w-3 h-3 rounded" style="background: #1e3a5f;"></div>
<span class="text-[10px] mono">AFM</span>
</div>
<div class="flex items-center gap-2 justify-center">
<div class="w-3 h-3 rounded" style="background: #2d1b4e;"></div>
<span class="text-[10px] mono">SC</span>
</div>
<div class="flex items-center gap-2 justify-center">
<div class="w-3 h-3 rounded" style="background: #4a1c1c;"></div>
<span class="text-[10px] mono">FL</span>
</div>
<div class="flex items-center gap-2 justify-center">
<div class="w-3 h-3 rounded" style="background: #1a3c34;"></div>
<span class="text-[10px] mono">NFL</span>
</div>
</div>
<!-- Sweep Progress -->
<div class="mt-4 p-3 bg-[#0a0e14] rounded-lg">
<div class="flex justify-between text-xs mono mb-2">
<span class="text-[#8b949e]">Sweep Progress</span>
<span id="sweepStatus" class="text-[#00d4aa]">IDLE</span>
</div>
<div class="w-full h-1.5 bg-[#1a222d] rounded-full overflow-hidden">
<div id="sweepProgress" class="h-full bg-gradient-to-r from-[#00d4aa] to-[#3b82f6] rounded-full transition-all duration-100" style="width: 0%"></div>
</div>
<div class="flex justify-between mt-2 text-[10px] mono text-[#8b949e]">
<span>T: <span id="currentT">0.0</span> K</span>
<span>H: <span id="currentH">0.0</span> T</span>
<span>Phase: <span id="currentPhase">--</span></span>
</div>
</div>
</section>
<!-- Right Panel: Measurements -->
<section class="col-span-12 lg:col-span-7 grid grid-rows-2 gap-4">
<!-- Transport Measurements -->
<div class="glass-panel glow-border p-4">
<div class="flex items-center justify-between mb-3">
<h2 class="font-medium text-sm uppercase tracking-wider text-[#8b949e]">Transport Measurements</h2>
<div class="flex gap-2">
<button id="btn-Rho" class="btn-control px-2 py-1 text-[10px] mono bg-[#00d4aa]/20 text-[#00d4aa] border border-[#00d4aa]/30 rounded">Rho(T)</button>
<button id="btn-MR" class="btn-control px-2 py-1 text-[10px] mono bg-[#1a222d] border border-[#2d3748] rounded hover:border-[#ff6b35] hover:text-[#ff6b35]">MR(H)</button>
<button id="btn-Hall" class="btn-control px-2 py-1 text-[10px] mono bg-[#1a222d] border border-[#2d3748] rounded hover:border-[#a855f7] hover:text-[#a855f7]">Hall</button>
</div>
</div>
<div class="bg-[#0a0e14] rounded-lg overflow-hidden" style="height: 200px;">
<canvas id="transportCanvas" class="w-full h-full"></canvas>
</div>
<div class="mt-3 grid grid-cols-4 gap-4 mono text-[10px]">
<div>
<span class="text-[#8b949e]">Rho(0)</span>
<p id="rho0" class="text-[#00d4aa]">-- mOhm-cm</p>
</div>
<div>
<span class="text-[#8b949e]">RRR</span>
<p id="rrr" class="text-[#00d4aa]">--</p>
</div>
<div>
<span class="text-[#8b949e]">Tc</span>
<p id="tc" class="text-[#ff6b35]">-- K</p>
</div>
<div>
<span class="text-[#8b949e]">Hc2</span>
<p id="hc2" class="text-[#ff6b35]">-- T</p>
</div>
</div>
</div>
<!-- Scanning Probe -->
<div class="glass-panel glow-border p-4">
<div class="flex items-center justify-between mb-3">
<h2 class="font-medium text-sm uppercase tracking-wider text-[#8b949e]">Scanning Probe Microscopy</h2>
<div class="flex gap-2">
<button id="btn-STS" class="btn-control px-2 py-1 text-[10px] mono bg-[#3b82f6]/20 text-[#3b82f6] border border-[#3b82f6]/30 rounded">STS Map</button>
<button id="btn-QPI" class="btn-control px-2 py-1 text-[10px] mono bg-[#1a222d] border border-[#2d3748] rounded hover:border-[#eab308] hover:text-[#eab308]">QPI</button>
</div>
</div>
<div class="grid grid-cols-2 gap-4">
<div class="bg-[#0a0e14] rounded-lg overflow-hidden relative" style="height: 180px;">
<canvas id="stmCanvas" class="w-full h-full"></canvas>
<div class="absolute top-2 left-2 text-[9px] mono text-[#8b949e]">dI/dV Map @ 4.2K</div>
</div>
<div class="bg-[#0a0e14] rounded-lg overflow-hidden relative" style="height: 180px;">
<canvas id="spectraCanvas" class="w-full h-full"></canvas>
<div class="absolute top-2 left-2 text-[9px] mono text-[#8b949e]">Local Spectrum</div>
</div>
</div>
<div class="mt-3 slider-container">
<div class="flex justify-between text-[10px] mono text-[#8b949e] mb-1">
<span>Sample Bias</span>
<span id="biasValue">0.0 mV</span>
</div>
<input type="range" id="biasSlider" min="-10" max="10" value="0" step="0.1">
</div>
</div>
</section>
<!-- Bottom Panel: Quantum Critical Region -->
<section class="col-span-12 glass-panel glow-border p-4">
<div class="flex items-center justify-between mb-4">
<h2 class="font-medium text-sm uppercase tracking-wider text-[#8b949e]">Quantum Critical Analysis</h2>
<div class="mono text-xs text-[#8b949e]">QCP: H = <span class="text-[#ff6b35]">8.3</span> T | T = <span class="text-[#ff6b35]">0</span> K</div>
</div>
<div class="grid grid-cols-12 gap-4">
<div class="col-span-4 bg-[#0a0e14] rounded-lg p-3">
<div class="text-[10px] mono text-[#8b949e] mb-2">Scaling Analysis</div>
<canvas id="scalingCanvas" style="width: 100%; height: 120px;"></canvas>
</div>
<div class="col-span-4 bg-[#0a0e14] rounded-lg p-3">
<div class="text-[10px] mono text-[#8b949e] mb-2">Specific Heat C/T</div>
<canvas id="heatCanvas" style="width: 100%; height: 120px;"></canvas>
</div>
<div class="col-span-4 bg-[#0a0e14] rounded-lg p-3">
<div class="text-[10px] mono text-[#8b949e] mb-2">Magnetic Susceptibility</div>
<canvas id="susceptCanvas" style="width: 100%; height: 120px;"></canvas>
</div>
</div>
<!-- Critical Exponents -->
<div class="mt-4 grid grid-cols-6 gap-3">
<div class="bg-[#0a0e14] rounded p-2 text-center">
<div class="text-[9px] mono text-[#8b949e]">alpha</div>
<div class="text-sm mono text-[#00d4aa]" id="exp-alpha">0.11</div>
</div>
<div class="bg-[#0a0e14] rounded p-2 text-center">
<div class="text-[9px] mono text-[#8b949e]">beta</div>
<div class="text-sm mono text-[#00d4aa]" id="exp-beta">0.33</div>
</div>
<div class="bg-[#0a0e14] rounded p-2 text-center">
<div class="text-[9px] mono text-[#8b949e]">gamma</div>
<div class="text-sm mono text-[#00d4aa]" id="exp-gamma">1.24</div>
</div>
<div class="bg-[#0a0e14] rounded p-2 text-center">
<div class="text-[9px] mono text-[#8b949e]">delta</div>
<div class="text-sm mono text-[#00d4aa]" id="exp-delta">4.8</div>
</div>
<div class="bg-[#0a0e14] rounded p-2 text-center">
<div class="text-[9px] mono text-[#8b949e]">nu</div>
<div class="text-sm mono text-[#00d4aa]" id="exp-nu">0.67</div>
</div>
<div class="bg-[#0a0e14] rounded p-2 text-center">
<div class="text-[9px] mono text-[#8b949e]">eta</div>
<div class="text-sm mono text-[#00d4aa]" id="exp-eta">0.04</div>
</div>
</div>
</section>
</main>
<script>
// ============ INITIALIZATION ============
const colors = {
cyan: '#00d4aa',
orange: '#ff6b35',
blue: '#3b82f6',
purple: '#a855f7',
yellow: '#eab308',
bg: '#0a0e14',
grid: '#1a222d',
text: '#8b949e'
};
// Physics parameters
const physics = {
Tc0: 2.1, // Critical temperature at H=0
Hc20: 12.5, // Upper critical field at T=0
TN: 4.2, // Neel temperature
H_QCP: 8.3, // Quantum critical field
rho0: 12.5, // Residual resistivity
RRR: 4.2, // Residual resistivity ratio
gamma_qcp: 1.24, // Critical exponent
nu: 0.67 // Correlation length exponent
};
// State
const state = {
sweepActive: false,
sweepType: null,
sweepProgress: 0,
currentT: 0,
currentH: 0,
currentPhase: 'PM',
transportMode: 'rho',
stmMode: 'sts',
bias: 0,
cursorPos: { x: 0.3, y: 0.7 },
time: 0
};
// Canvas contexts - initialized after DOM ready
let phaseCtx, transportCtx, stmCtx, spectraCtx;
let scalingCtx, heatCtx, susceptCtx;
let phaseCanvas, transportCanvas, stmCanvas, spectraCanvas;
let scalingCanvas, heatCanvas, susceptCanvas;
// ============ UTILITY FUNCTIONS ============
function lerp(a, b, t) {
return a + (b - a) * t;
}
function clamp(val, min, max) {
return Math.max(min, Math.min(max, val));
}
function smoothstep(edge0, edge1, x) {
const t = clamp((x - edge0) / (edge1 - edge0), 0, 1);
return t * t * (3 - 2 * t);
}
// Simplex-like noise
function noise2D(x, y) {
const X = Math.floor(x) & 255;
const Y = Math.floor(y) & 255;
x -= Math.floor(x);
y -= Math.floor(y);
const u = x * x * (3 - 2 * x);
const v = y * y * (3 - 2 * y);
const a = (Math.sin(X * 127.1 + Y * 311.7) * 43758.5453) % 1;
const b = (Math.sin((X + 1) * 127.1 + Y * 311.7) * 43758.5453) % 1;
const c = (Math.sin(X * 127.1 + (Y + 1) * 311.7) * 43758.5453) % 1;
const d = (Math.sin((X + 1) * 127.1 + (Y + 1) * 311.7) * 43758.5453) % 1;
return lerp(lerp(a, b, u), lerp(c, d, u), v);
}
// ============ PHYSICS CALCULATIONS ============
function getPhase(T, H) {
// Superconducting phase boundary (Werthamer-Helfand-Hohenberg)
const Hc2 = physics.Hc20 * (1 - (T / physics.Tc0) * (T / physics.Tc0));
if (T < physics.Tc0 && H < Math.max(0, Hc2)) return 'SC';
// Antiferromagnetic phase
const H_Neel = 6 + 2 * Math.exp(-T / 2);
if (T < physics.TN && H < H_Neel) return 'AFM';
// Non-Fermi liquid near QCP
const dist_QCP = Math.sqrt((T - 0) * (T - 0) + (H - physics.H_QCP) * (H - physics.H_QCP));
if (dist_QCP < 3) return 'NFL';
// Fermi liquid
return 'FL';
}
function getPhaseColor(phase) {
switch(phase) {
case 'SC': return { r: 45, g: 27, b: 78 };
case 'AFM': return { r: 30, g: 58, b: 95 };
case 'NFL': return { r: 26, g: 60, b: 52 };
case 'FL': return { r: 74, g: 28, b: 28 };
default: return { r: 20, g: 25, b: 35 };
}
}
function resistivity(T, H) {
const phase = getPhase(T, H);
if (phase === 'SC') return 0;
let rho = physics.rho0;
const phase_mb = physics;
if (phase === 'FL') {
rho += 0.8 * T * T;
} else if (phase === 'NFL') {
const dist = Math.abs(H - physics.H_QCP);
const exponent = 1.5 - 0.3 / (1 + dist);
rho += 2.5 * Math.pow(T, exponent);
} else if (phase === 'AFM') {
rho += 1.2 * T * Math.exp(-physics.TN / (T + 0.1));
}
// Magnetoresistance
rho *= (1 + 0.02 * H * H);
return rho;
}
function hallCoefficient(T, H) {
const phase = getPhase(T, H);
let RH = 1e-3; // Base Hall coefficient
if (phase === 'NFL') {
RH *= (1 + 0.5 * Math.log(T + 1));
}
return RH;
}
function specificHeat(T, H) {
const phase = getPhase(T, H);
let C = 0.4 * T; // Electronic contribution
if (phase === 'AFM') {
C += 0.3 * Math.pow(T / physics.TN, 3);
}
// Divergence near QCP
const dist = Math.abs(H - physics.H_QCP);
if (dist < 3) {
C *= (1 + 0.3 / Math.pow(T + 0.5, 0.5));
}
return C;
}
// ============ RENDERING FUNCTIONS ============
function renderPhaseDiagram() {
if (!phaseCtx) return;
const w = phaseCanvas.width;
const h = phaseCanvas.height;
const imageData = phaseCtx.createImageData(w, h);
const data = imageData.data;
const maxT = 20;
const maxH = 15;
for (let py = 0; py < h; py++) {
for (let px = 0; px < w; px++) {
const T = (1 - py / h) * maxT;
const H = (px / w) * maxH;
const phase = getPhase(T, H);
const baseColor = getPhaseColor(phase);
// Add gradient and texture
const noise = noise2D(px * 0.05, py * 0.05) * 10;
// Phase boundary glow
let glow = 0;
const Hc2 = physics.Hc20 * (1 - (T / physics.Tc0) * (T / physics.Tc0));
if (T < physics.Tc0 && H > 0 && H < Hc2 + 1) {
glow = 30 * Math.exp(-Math.abs(H - Hc2) * 3);
}
const idx = (py * w + px) * 4;
data[idx] = clamp(baseColor.r + noise + glow, 0, 255);
data[idx + 1] = clamp(baseColor.g + noise * 0.5 + glow * 0.5, 0, 255);
data[idx + 2] = clamp(baseColor.b + noise * 0.3 + glow * 0.3, 0, 255);
data[idx + 3] = 255;
}
}
phaseCtx.putImageData(imageData, 0, 0);
// Draw grid
phaseCtx.strokeStyle = 'rgba(45, 55, 72, 0.5)';
phaseCtx.lineWidth = 0.5;
for (let i = 0; i <= 5; i++) {
const x = (i / 5) * w;
const y = (i / 5) * h;
phaseCtx.beginPath();
phaseCtx.moveTo(x, 0);
phaseCtx.lineTo(x, h);
phaseCtx.stroke();
phaseCtx.beginPath();
phaseCtx.moveTo(0, y);
phaseCtx.lineTo(w, y);
phaseCtx.stroke();
}
// Draw QCP marker
const qcpX = (physics.H_QCP / maxH) * w;
const qcpY = h;
phaseCtx.fillStyle = colors.orange;
phaseCtx.beginPath();
phaseCtx.arc(qcpX, qcpY - 5, 5, 0, Math.PI * 2);
phaseCtx.fill();
// Draw sweep line
if (state.sweepActive) {
phaseCtx.strokeStyle = colors.cyan;
phaseCtx.lineWidth = 2;
phaseCtx.setLineDash([5, 5]);
phaseCtx.beginPath();
if (state.sweepType === 'T') {
const x = (state.currentH / maxH) * w;
phaseCtx.moveTo(x, 0);
phaseCtx.lineTo(x, h);
} else {
const y = (1 - state.currentT / maxT) * h;
phaseCtx.moveTo(0, y);
phaseCtx.lineTo(w, y);
}
phaseCtx.stroke();
phaseCtx.setLineDash([]);
// Current position marker
const markerX = (state.currentH / maxH) * w;
const markerY = (1 - state.currentT / maxT) * h;
phaseCtx.fillStyle = colors.cyan;
phaseCtx.beginPath();
phaseCtx.arc(markerX, markerY, 6, 0, Math.PI * 2);
phaseCtx.fill();
phaseCtx.strokeStyle = '#ffffff';
phaseCtx.lineWidth = 2;
phaseCtx.stroke();
}
}
function renderTransport() {
if (!transportCtx) return;
const w = transportCanvas.width;
const h = transportCanvas.height;
transportCtx.fillStyle = colors.bg;
transportCtx.fillRect(0, 0, w, h);
const padding = { left: 50, right: 20, top: 20, bottom: 30 };
const plotW = w - padding.left - padding.right;
const plotH = h - padding.top - padding.bottom;
// Grid
transportCtx.strokeStyle = colors.grid;
transportCtx.lineWidth = 0.5;
for (let i = 0; i <= 5; i++) {
const x = padding.left + (i / 5) * plotW;
const y = padding.top + (i / 5) * plotH;
transportCtx.beginPath();
transportCtx.moveTo(x, padding.top);
transportCtx.lineTo(x, h - padding.bottom);
transportCtx.stroke();
transportCtx.beginPath();
transportCtx.moveTo(padding.left, y);
transportCtx.lineTo(w - padding.right, y);
transportCtx.stroke();
}
// Axes
transportCtx.strokeStyle = colors.text;
transportCtx.lineWidth = 1;
transportCtx.beginPath();
transportCtx.moveTo(padding.left, padding.top);
transportCtx.lineTo(padding.left, h - padding.bottom);
transportCtx.lineTo(w - padding.right, h - padding.bottom);
transportCtx.stroke();
// Plot data
const plotData = [];
const sweepProgress = state.sweepActive ? state.sweepProgress : 1;
if (state.transportMode === 'rho') {
// Resistivity vs T
transportCtx.fillStyle = colors.text;
transportCtx.font = '9px JetBrains Mono';
transportCtx.fillText('T (K)', w / 2, h - 5);
transportCtx.save();
transportCtx.translate(12, h / 2);
transportCtx.rotate(-Math.PI / 2);
transportCtx.fillText('ρ (mΩ·cm)', 0, 0);
transportCtx.restore();
const H = state.sweepType === 'H' ? state.currentH : 5;
for (let i = 0; i <= 100 * sweepProgress; i++) {
const T = (i / 100) * 20;
const rho = resistivity(T, H);
plotData.push({ x: T / 20, y: rho / 30 });
}
} else if (state.transportMode === 'mr') {
transportCtx.fillText('H (T)', w / 2, h - 5);
transportCtx.save();
transportCtx.translate(12, h / 2);
transportCtx.rotate(-Math.PI / 2);
transportCtx.fillText('MR (%)', 0, 0);
transportCtx.restore();
const T = state.currentT || 2;
const rho0 = resistivity(T, 0);
for (let i = 0; i <= 100 * sweepProgress; i++) {
const H = (i / 100) * 15;
const rho = resistivity(T, H);
const mr = ((rho - rho0) / rho0) * 100;
plotData.push({ x: H / 15, y: (mr + 20) / 40 });
}
} else if (state.transportMode === 'hall') {
transportCtx.fillText('H (T)', w / 2, h - 5);
transportCtx.save();
transportCtx.translate(12, h / 2);
transportCtx.rotate(-Math.PI / 2);
transportCtx.fillText('RH (a.u.)', 0, 0);
transportCtx.restore();
const T = state.currentT || 5;
for (let i = 0; i <= 100 * sweepProgress; i++) {
const H = (i / 100) * 15;
const RH = hallCoefficient(T, H);
plotData.push({ x: H / 15, y: RH * 500 + 0.5 });
}
}
// Draw curve
if (plotData.length > 1) {
const gradient = transportCtx.createLinearGradient(padding.left, 0, w - padding.right, 0);
gradient.addColorStop(0, colors.cyan);
gradient.addColorStop(1, colors.blue);
transportCtx.strokeStyle = gradient;
transportCtx.lineWidth = 2;
transportCtx.beginPath();
plotData.forEach((pt, i) => {
const x = padding.left + pt.x * plotW;
const y = h - padding.bottom - clamp(pt.y, 0, 1) * plotH;
if (i === 0) transportCtx.moveTo(x, y);
else transportCtx.lineTo(x, y);
});
transportCtx.stroke();
// Glow effect
transportCtx.shadowColor = colors.cyan;
transportCtx.shadowBlur = 10;
transportCtx.stroke();
transportCtx.shadowBlur = 0;
}
}
function renderSTM() {
if (!stmCtx) return;
const w = stmCanvas.width;
const h = stmCanvas.height;
const imageData = stmCtx.createImageData(w, h);
const data = imageData.data;
const bias = state.bias;
const time = state.time;
for (let py = 0; py < h; py++) {
for (let px = 0; px < w; px++) {
const x = px / w;
const y = py / h;
// Simulated LDOS with quantum oscillations
let ldos = 0.5;
ldos += 0.2 * Math.sin(x * 20 + time * 0.5) * Math.sin(y * 20);
ldos += 0.15 * Math.sin((x + y) * 30 - time * 0.3);
ldos += 0.1 * noise2D(px * 0.1 + time * 0.1, py * 0.1);
// Energy gap signature
const gap = 0.5; // meV
if (Math.abs(bias) < gap) {
ldos *= 0.3 + 0.7 * (bias * bias) / (gap * gap);
}
// Vortex lattice at finite field
if (state.currentH > 1) {
const vortexSpacing = 20 / Math.sqrt(state.currentH);
const vx = (x * w / vortexSpacing) % 1;
const vy = (y * h / vortexSpacing) % 1;
const vortexDist = Math.sqrt((vx - 0.5) * (vx - 0.5) + (vy - 0.5) * (vy - 0.5));
ldos += 0.3 * Math.exp(-vortexDist * 10);
}
ldos = clamp(ldos, 0, 1);
// Colormap: blue -> cyan -> yellow
let r, g, b;
if (ldos < 0.5) {
r = lerp(20, 0, ldos * 2);
g = lerp(30, 212, ldos * 2);
b = lerp(80, 170, ldos * 2);
} else {
r = lerp(0, 234, (ldos - 0.5) * 2);
g = lerp(212, 179, (ldos - 0.5) * 2);
b = lerp(170, 8, (ldos - 0.5) * 2);
}
const idx = (py * w + px) * 4;
data[idx] = r;
data[idx + 1] = g;
data[idx + 2] = b;
data[idx + 3] = 255;
}
}
stmCtx.putImageData(imageData, 0, 0);
}
function renderSpectra() {
if (!spectraCtx) return;
const w = spectraCanvas.width;
const h = spectraCanvas.height;
spectraCtx.fillStyle = colors.bg;
spectraCtx.fillRect(0, 0, w, h);
const padding = { left: 30, right: 10, top: 10, bottom: 20 };
const plotW = w - padding.left - padding.right;
const plotH = h - padding.top - padding.bottom;
// Axes
spectraCtx.strokeStyle = colors.text;
spectraCtx.lineWidth = 0.5;
spectraCtx.beginPath();
spectraCtx.moveTo(padding.left, padding.top);
spectraCtx.lineTo(padding.left, h - padding.bottom);
spectraCtx.lineTo(w - padding.right, h - padding.bottom);
spectraCtx.stroke();
// STS spectrum with superconducting gap
const gap = 0.5;
const spectrum = [];
for (let i = 0; i <= 100; i++) {
const E = (i / 100) * 20 - 10; // -10 to +10 mV
let dos = Math.abs(E) / Math.sqrt(E * E + gap * gap);
dos += 0.1 * noise2D(i * 0.1, state.time * 0.1);
spectrum.push({ x: i / 100, y: clamp(dos, 0, 2) / 2 });
}
// Draw spectrum
spectraCtx.strokeStyle = colors.blue;
spectraCtx.lineWidth = 1.5;
spectraCtx.beginPath();
spectrum.forEach((pt, i) => {
const x = padding.left + pt.x * plotW;
const y = h - padding.bottom - pt.y * plotH;
if (i === 0) spectraCtx.moveTo(x, y);
else spectraCtx.lineTo(x, y);
});
spectraCtx.stroke();
// Gap markers
const gapX1 = padding.left + ((10 - gap) / 20) * plotW;
const gapX2 = padding.left + ((10 + gap) / 20) * plotW;
spectraCtx.strokeStyle = colors.orange;
spectraCtx.setLineDash([2, 2]);
spectraCtx.beginPath();
spectraCtx.moveTo(gapX1, padding.top);
spectraCtx.lineTo(gapX1, h - padding.bottom);
spectraCtx.moveTo(gapX2, padding.top);
spectraCtx.lineTo(gapX2, h - padding.bottom);
spectraCtx.stroke();
spectraCtx.setLineDash([]);
// Bias line
const biasX = padding.left + ((state.bias + 10) / 20) * plotW;
spectraCtx.strokeStyle = colors.cyan;
spectraCtx.lineWidth = 2;
spectraCtx.beginPath();
spectraCtx.moveTo(biasX, padding.top);
spectraCtx.lineTo(biasX, h - padding.bottom);
spectraCtx.stroke();
}
function renderScaling() {
if (!scalingCtx) return;
const w = scalingCanvas.width;
const h = scalingCanvas.height;
scalingCtx.fillStyle = colors.bg;
scalingCtx.fillRect(0, 0, w, h);
const padding = 25;
const plotW = w - padding * 2;
const plotH = h - padding * 2;
// Scaling collapse plot
scalingCtx.strokeStyle = colors.grid;
scalingCtx.lineWidth = 0.5;
scalingCtx.strokeRect(padding, padding, plotW, plotH);
// Data points with scaling
const data = [];
const fields = [6, 7, 8, 8.3, 9, 10];
fields.forEach((H, fi) => {
const curve = [];
for (let i = 0; i <= 30; i++) {
const T = (i / 30) * 10;
let rho = resistivity(T, H) - physics.rho0;
// Scale
const r = Math.abs(H - physics.H_QCP) / Math.pow(T, 1 / (physics.nu * 2 + 1));
const scaledRho = rho / Math.pow(Math.abs(H - physics.H_QCP), 0.5);
curve.push({ x: r / 5, y: scaledRho / 15, fi });
}
data.push(curve);
});
const lineColors = ['#ff6b35', '#ff8c5a', '#00d4aa', '#3b82f6', '#a855f7', '#eab308'];
data.forEach((curve, ci) => {
scalingCtx.strokeStyle = lineColors[ci % lineColors.length];
scalingCtx.lineWidth = 1;
scalingCtx.beginPath();
curve.forEach((pt, i) => {
const x = padding + clamp(pt.x, 0, 1) * plotW;
const y = padding + (1 - clamp(pt.y, 0, 1)) * plotH;
if (i === 0) scalingCtx.moveTo(x, y);
else scalingCtx.lineTo(x, y);
});
scalingCtx.stroke();
});
}
function renderHeat() {
if (!heatCtx) return;
const w = heatCanvas.width;
const h = heatCanvas.height;
heatCtx.fillStyle = colors.bg;
heatCtx.fillRect(0, 0, w, h);
const padding = 25;
const plotW = w - padding * 2;
const plotH = h - padding * 2;
heatCtx.strokeStyle = colors.grid;
heatCtx.lineWidth = 0.5;
heatCtx.strokeRect(padding, padding, plotW, plotH);
const fields = [0, 6, 8.3, 12];
const lineColors = [colors.text, colors.yellow, colors.orange, colors.cyan];
fields.forEach((H, fi) => {
const curve = [];
for (let i = 1; i <= 50; i++) {
const T = (i / 50) * 10;
const C = specificHeat(T, H);
curve.push({ x: T / 10, y: C / T / 0.8 });
}
heatCtx.strokeStyle = lineColors[fi];
heatCtx.lineWidth = 1.5;
heatCtx.beginPath();
curve.forEach((pt, i) => {
const x = padding + clamp(pt.x, 0, 1) * plotW;
const y = padding + (1 - clamp(pt.y, 0, 1)) * plotH;
if (i === 0) heatCtx.moveTo(x, y);
else heatCtx.lineTo(x, y);
});
heatCtx.stroke();
});
}
function renderSuscept() {
if (!susceptCtx) return;
const w = susceptCanvas.width;
const h = susceptCanvas.height;
susceptCtx.fillStyle = colors.bg;
susceptCtx.fillRect(0, 0, w, h);
const padding = 25;
const plotW = w - padding * 2;
const plotH = h - padding * 2;
susceptCtx.strokeStyle = colors.grid;
susceptCtx.lineWidth = 0.5;
susceptCtx.strokeRect(padding, padding, plotW, plotH);
// Chi(T) curves
const fields = [0, 4, 8.3];
const lineColors = [colors.purple, colors.blue, colors.orange];
fields.forEach((H, fi) => {
const curve = [];
for (let i = 1; i <= 50; i++) {
const T = (i / 50) * 20;
let chi = 1 / (T + 2);
if (Math.abs(H - physics.H_QCP) < 1) {
chi = Math.pow(T, -0.7) * 0.5;
}
curve.push({ x: T / 20, y: chi / 2 });
}
susceptCtx.strokeStyle = lineColors[fi];
susceptCtx.lineWidth = 1.5;
susceptCtx.beginPath();
curve.forEach((pt, i) => {
const x = padding + clamp(pt.x, 0, 1) * plotW;
const y = padding + (1 - clamp(pt.y, 0, 1)) * plotH;
if (i === 0) susceptCtx.moveTo(x, y);
else susceptCtx.lineTo(x, y);
});
susceptCtx.stroke();
});
}
// ============ SWEEP ANIMATION ============
function startSweep(type) {
state.sweepActive = true;
state.sweepType = type;
state.sweepProgress = 0;
if (type === 'T') {
state.currentH = 5;
state.currentT = 0;
} else {
state.currentT = 2;
state.currentH = 0;
}
document.getElementById('sweepStatus').textContent = type + '-SWEEP';
}
function updateSweep() {
if (!state.sweepActive) return;
state.sweepProgress += 0.005;
if (state.sweepProgress >= 1) {
state.sweepActive = false;
state.sweepProgress = 1;
document.getElementById('sweepStatus').textContent = 'COMPLETE';
setTimeout(() => {
document.getElementById('sweepStatus').textContent = 'IDLE';
}, 2000);
}
if (state.sweepType === 'T') {
state.currentT = state.sweepProgress * 20;
} else {
state.currentH = state.sweepProgress * 15;
}
state.currentPhase = getPhase(state.currentT, state.currentH);
// Update UI
document.getElementById('sweepProgress').style.width = (state.sweepProgress * 100) + '%';
document.getElementById('currentT').textContent = state.currentT.toFixed(1);
document.getElementById('currentH').textContent = state.currentH.toFixed(1);
document.getElementById('currentPhase').textContent = state.currentPhase;
// Update transport measurements
document.getElementById('rho0').textContent = physics.rho0.toFixed(1) + ' mOhm-cm';
document.getElementById('rrr').textContent = physics.RRR.toFixed(1);
if (state.currentPhase === 'SC') {
document.getElementById('tc').textContent = state.currentT.toFixed(2) + ' K';
}
if (state.currentH > 0 && state.currentPhase === 'SC') {
document.getElementById('hc2').textContent = state.currentH.toFixed(1) + ' T';
}
}
// ============ EVENT HANDLERS ============
function setupEventListeners() {
document.getElementById('btn-TSweep').addEventListener('click', () => startSweep('T'));
document.getElementById('btn-HSweep').addEventListener('click', () => startSweep('H'));
document.getElementById('btn-Rho').addEventListener('click', function() {
state.transportMode = 'rho';
updateTransportButtons(this);
});
document.getElementById('btn-MR').addEventListener('click', function() {
state.transportMode = 'mr';
updateTransportButtons(this);
});
document.getElementById('btn-Hall').addEventListener('click', function() {
state.transportMode = 'hall';
updateTransportButtons(this);
});
document.getElementById('biasSlider').addEventListener('input', function() {
state.bias = parseFloat(this.value);
document.getElementById('biasValue').textContent = state.bias.toFixed(1) + ' mV';
});
// Phase diagram click to set position
phaseCanvas.addEventListener('click', function(e) {
const rect = this.getBoundingClientRect();
const x = (e.clientX - rect.left) / rect.width;
const y = 1 - (e.clientY - rect.top) / rect.height;
state.currentT = y * 20;
state.currentH = x * 15;
state.currentPhase = getPhase(state.currentT, state.currentH);
document.getElementById('currentT').textContent = state.currentT.toFixed(1);
document.getElementById('currentH').textContent = state.currentH.toFixed(1);
document.getElementById('currentPhase').textContent = state.currentPhase;
});
}
function updateTransportButtons(activeBtn) {
document.querySelectorAll('#btn-Rho, #btn-MR, #btn-Hall').forEach(btn => {
btn.classList.remove('bg-[#00d4aa]/20', 'text-[#00d4aa]', 'border-[#00d4aa]/30');
btn.classList.add('bg-[#1a222d]', 'border-[#2d3748]');
});
activeBtn.classList.remove('bg-[#1a222d]', 'border-[#2d3748]');
activeBtn.classList.add('bg-[#00d4aa]/20', 'text-[#00d4aa]', 'border-[#00d4aa]/30');
}
// ============ RESIZE HANDLER ============
function resizeCanvases() {
const canvases = [
{ canvas: phaseCanvas, ctx: 'phaseCtx' },
{ canvas: transportCanvas, ctx: 'transportCtx' },
{ canvas: stmCanvas, ctx: 'stmCtx' },
{ canvas: spectraCanvas, ctx: 'spectraCtx' },
{ canvas: scalingCanvas, ctx: 'scalingCtx' },
{ canvas: heatCanvas, ctx: 'heatCtx' },
{ canvas: susceptCanvas, ctx: 'susceptCtx' }
];
canvases.forEach(({ canvas, ctx }) => {
if (canvas) {
const rect = canvas.parentElement.getBoundingClientRect();
const dpr = window.devicePixelRatio || 1;
canvas.width = rect.width * dpr;
canvas.height = rect.height * dpr;
canvas.style.width = rect.width + 'px';
canvas.style.height = rect.height + 'px';
const context = canvas.getContext('2d');
context.scale(dpr, dpr);
}
});
}
// ============ MAIN LOOP ============
function updateClock() {
const now = new Date();
document.getElementById('clock').textContent = now.toLocaleTimeString('en-US', { hour12: false });
}
function animate() {
state.time += 0.016;
updateSweep();
renderPhaseDiagram();
renderTransport();
renderSTM();
renderSpectra();
renderScaling();
renderHeat();
renderSuscept();
requestAnimationFrame(animate);
}
// ============ INITIALIZATION ============
function init() {
// Initialize canvas references
phaseCanvas = document.getElementById('phaseCanvas');
transportCanvas = document.getElementById('transportCanvas');
stmCanvas = document.getElementById('stmCanvas');
spectraCanvas = document.getElementById('spectraCanvas');
scalingCanvas = document.getElementById('scalingCanvas');
heatCanvas = document.getElementById('heatCanvas');
susceptCanvas = document.getElementById('susceptCanvas');
// Initialize contexts
phaseCtx = phaseCanvas.getContext('2d');
transportCtx = transportCanvas.getContext('2d');
stmCtx = stmCanvas.getContext('2d');
spectraCtx = spectraCanvas.getContext('2d');
scalingCtx = scalingCanvas.getContext('2d');
heatCtx = heatCanvas.getContext('2d');
susceptCtx = susceptCanvas.getContext('2d');
resizeCanvases();
setupEventListeners();
setInterval(updateClock, 1000);
updateClock();
animate();
}
window.addEventListener('resize', resizeCanvases);
document.addEventListener('DOMContentLoaded', init);
</script>
</body>
</html>