Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 2

<!

DOCTYPE html>
<html>
<head>
<title>Poço do Quadrado Infinito</title>
<script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
<style>
body {
font-family: Arial, sans-serif;
margin: 20px;
}

h1, h2 {
margin-bottom: 10px;
}

label {
display: inline-block;
width: 120px;
}

input[type="number"] {
width: 100px;
}

button {
padding: 5px 10px;
font-size: 16px;
}

#energies, #wavefunctions {
margin-top: 10px;
}

#wavefunctions {
max-width: 800px;
}
</style>
</head>
<body>
<h1>Poço do Quadrado Infinito</h1>

<h2>Parâmetros do Poço:</h2>
<label for="well-length">Comprimento:</label>
<input type="number" id="well-length" step="0.1" value="1.0"><br>

<label for="num-points">Número de pontos:</label>


<input type="number" id="num-points" step="1" value="100"><br>

<button onclick="calculate()">Calcular</button>

<h2>Energias permitidas:</h2>
<div id="energies"></div>

<h2>Funções de Onda:</h2>
<div id="wavefunctions"></div>

<script type="text/javascript">
function infiniteSquareWell(length, numPoints) {
// Código Python aqui
// ...
}

function calculate() {
var wellLengthInput = document.getElementById("well-length");
var numPointsInput = document.getElementById("num-points");

var wellLength = parseFloat(wellLengthInput.value);


var numPoints = parseInt(numPointsInput.value);

// Cálculo das energias e das funções de onda


var result = infiniteSquareWell(wellLength, numPoints);
var energies = result[0];
var wavefunctions = result[1];

// Exibir as energias permitidas


var energiesDiv = document.getElementById("energies");
energiesDiv.innerHTML = "";
for (var i = 0; i < energies.length; i++) {
var energy = energies[i].toFixed(4);
var level = i + 1;
energiesDiv.innerHTML += "<p>Nível " + level + ": " + energy + " eV</p>";
}

// Plotar as funções de onda


var wavefunctionsDiv = document.getElementById("wavefunctions");
wavefunctionsDiv.innerHTML = "";
for (var i = 0; i < 5; i++) {
var data = [{
x: Array.from(Array(numPoints).keys()),
y: wavefunctions[i],
type: 'scatter',
name: "Nível " + (i + 1)
}];
var layout = {
title: 'Função de Onda',
xaxis: { title: 'Posição' },
yaxis: { title: 'Função de Onda' }
};
Plotly.newPlot(wavefunctionsDiv, data, layout);
}
}
</script>
</body>
</html>

You might also like