Activation Energy to Rate Constant Converter

Calculated using Arrhenius equation: k = A·e-Ea/RT

`; // Populate table const tableBody = document.getElementById('result-table-body'); tableBody.innerHTML = ` Activation Energy ${Ea} ${energyUnit} Temperature ${T} K Pre-exponential Factor ${A.toExponential(4)} ${Aunit} Rate Constant ${k.toExponential(4)} ${Aunit} Ea/RT ${(Ea_J / (R * T)).toFixed(2)} dimensionless `; // Create Arrhenius plot createArrheniusPlot(temps, rateConstants, T, k); document.getElementById('results').style.display = 'block'; } function createArrheniusPlot(temps, rateConstants, selectedT, selectedK) { const plot = document.getElementById('arrhenius-plot'); plot.innerHTML = ''; // Find min/max values for scaling const minT = Math.min(...temps); const maxT = Math.max(...temps); const minK = Math.min(...rateConstants); const maxK = Math.max(...rateConstants); // Add axes labels const xLabel = document.createElement('div'); xLabel.className = 'plot-label x-axis'; xLabel.textContent = 'Temperature (K)'; plot.appendChild(xLabel); const yLabel = document.createElement('div'); yLabel.className = 'plot-label y-axis'; yLabel.textContent = 'Rate Constant k'; plot.appendChild(yLabel); // Plot area dimensions const plotWidth = plot.offsetWidth - 40; const plotHeight = plot.offsetHeight - 40; const plotLeft = 30; const plotBottom = plot.offsetHeight - 30; // Draw axes const xAxis = document.createElement('div'); xAxis.className = 'plot-line'; xAxis.style.left = `${plotLeft}px`; xAxis.style.bottom = `${plotBottom}px`; xAxis.style.width = `${plotWidth}px`; xAxis.style.height = '1px'; plot.appendChild(xAxis); const yAxis = document.createElement('div'); yAxis.className = 'plot-line'; yAxis.style.left = `${plotLeft}px`; yAxis.style.bottom = `${plotBottom - plotHeight}px`; yAxis.style.width = '1px'; yAxis.style.height = `${plotHeight}px`; plot.appendChild(yAxis); // Plot points temps.forEach((t, i) => { const x = plotLeft + ((t - minT) / (maxT - minT)) * plotWidth; const y = plotBottom - ((Math.log(rateConstants[i]) - Math.log(minK)) / (Math.log(maxK) - Math.log(minK))) * plotHeight; const point = document.createElement('div'); point.className = 'plot-point'; point.style.left = `${x}px`; point.style.bottom = `${y}px`; // Highlight the selected temperature point if (Math.abs(t - selectedT) < 0.1) { point.style.width = '12px'; point.style.height = '12px'; point.style.backgroundColor = '#e74a3b'; } plot.appendChild(point); }); } function generatePDF() { try { const { jsPDF } = window.jspdf; const doc = new jsPDF(); // Title doc.setFontSize(18); doc.text('Activation Energy Conversion Report', 105, 15, { align: 'center' }); // Date doc.setFontSize(10); doc.text(`Generated: ${new Date().toLocaleString()}`, 105, 22, { align: 'center' }); // Add results summary doc.setFontSize(12); const resultValues = document.getElementById('result-values').textContent; const lines = resultValues.split('\n').filter(line => line.trim() !== ''); let yPos = 40; lines.forEach(line => { doc.text(line.trim(), 14, yPos); yPos += 7; }); // Add table data yPos += 10; doc.setFontSize(14); doc.text('Detailed Parameters:', 14, yPos); yPos += 10; doc.setFontSize(12); const table = document.getElementById('result-table-body'); const rows = table.querySelectorAll('tr'); rows.forEach(row => { const cells = row.querySelectorAll('td'); doc.text(`${cells[0].textContent}: ${cells[1].textContent} ${cells[2].textContent}`, 20, yPos); yPos += 7; }); // Add note about plot yPos += 10; doc.text('Note: The Arrhenius plot is available in the web version.', 14, yPos); // Save PDF doc.save('Activation_Energy_Conversion_Report.pdf'); } catch (error) { console.error('PDF generation error:', error); alert('PDF generation failed. Please try again or check your internet connection.'); } }
Scroll to Top