{"id":757,"date":"2024-11-27T15:48:21","date_gmt":"2024-11-27T15:48:21","guid":{"rendered":"https:\/\/hintek.se\/?page_id=757"},"modified":"2025-09-15T18:15:40","modified_gmt":"2025-09-15T18:15:40","slug":"faskompensering1","status":"publish","type":"page","link":"https:\/\/hintek.se\/index.php\/faskompensering1\/","title":{"rendered":"Faskompensering1"},"content":{"rendered":"\n<p class=\"has-text-align-center wp-block-paragraph\">Version 1<\/p>\n\n\n    <style>\r\n.custom-faskompensering {\r\n    font-family: Arial, sans-serif;\r\n    color: #333;\r\n    background-color: white;\r\n    padding: 0;\r\n}\r\n.custom-faskompensering .container {\r\n    max-width: 800px;\r\n    margin: 20px auto;\r\n    background: #ffffff;\r\n    border-radius: 8px;\r\n    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);\r\n    padding: 20px;\r\n}\r\n.custom-faskompensering h1, \r\n.custom-faskompensering h2, \r\n.custom-faskompensering h3 {\r\n    text-align: center;\r\n}\r\n.custom-faskompensering label {\r\n    display: block;\r\n    margin: 10px 0 5px;\r\n    font-weight: bold;\r\n}\r\n.custom-faskompensering .input-container {\r\n    position: relative;\r\n    margin-bottom: 20px;\r\n}\r\n.custom-faskompensering input, \r\n.custom-faskompensering select {\r\n    width: 100%;\r\n    padding: 10px;\r\n    font-size: 16px;\r\n    border: 1px solid #ccc;\r\n    border-radius: 4px;\r\n    box-sizing: border-box;\r\n}\r\n.custom-faskompensering .row {\r\n    display: flex;\r\n    justify-content: space-between;\r\n    flex-wrap: wrap;\r\n}\r\n.custom-faskompensering .row div {\r\n    flex: 1 1 45%;\r\n    position: relative;\r\n    margin-right: 10px;\r\n    margin-bottom: 15px;\r\n}\r\n.custom-faskompensering .row div:last-child {\r\n    margin-right: 0;\r\n}\r\n.custom-faskompensering .current-field {\r\n    flex: 1 1 30%;\r\n}\r\n.custom-faskompensering button {\r\n    width: 100%;\r\n    padding: 10px;\r\n    background-color: #007bff;\r\n    color: white;\r\n    font-size: 16px;\r\n    border: none;\r\n    border-radius: 4px;\r\n    cursor: pointer;\r\n    display: none;\r\n}\r\n.custom-faskompensering button:hover {\r\n    background-color: #0056b3;\r\n}\r\n.custom-faskompensering .results {\r\n    margin-top: 20px;\r\n    background: #ffffff;\r\n    border: 1px solid #ccc;\r\n    border-radius: 4px;\r\n    padding: 20px;\r\n    font-size: 16px;\r\n    line-height: 1.6;\r\n}\r\n.unit-circle-container {\r\n    text-align: center;\r\n    margin-top: 20px;\r\n}\r\ncanvas {\r\n    border: 1px solid #ccc;\r\n    margin-top: 20px;\r\n    max-width: 100%;\r\n    height: auto;\r\n}\r\n@media (max-width: 600px) {\r\n    .custom-faskompensering .row div {\r\n        flex: 1 1 100%;\r\n        margin-right: 0;\r\n    }\r\n    .custom-faskompensering .current-field {\r\n        flex: 1 1 100%;\r\n    }\r\n}\r\n.error-message {\r\n    position: static;\r\n    margin-top: 5px;\r\n    color: red;\r\n    font-size: 12px;\r\n    display: none;\r\n}\r\n.input-error {\r\n    border-color: red;\r\n}\r\n.checkbox-container {\r\n    display: flex;\r\n    align-items: center;\r\n    margin-bottom: 15px;\r\n    gap: 10px;\r\n}\r\n.checkbox-container input {\r\n    margin-right: 10px;\r\n    width: auto;\r\n}\r\n.checkbox-container input[type=\"checkbox\"] {\r\n    transform: scale(1.5); \/* F\u00f6rstorar checkboxen *\/\r\n    width: 20px; \/* Bredden p\u00e5 checkboxen *\/\r\n    height: 20px; \/* H\u00f6jden p\u00e5 checkboxen *\/\r\n    margin-right: 10px; \/* Avst\u00e5nd mellan checkbox och text *\/\r\n}\r\n.checkbox-container label {\r\n    font-size: 14px;\r\n    display: inline-block;\r\n    margin: 0;\r\n    padding: 0;\r\n}\r\n\/* F\u00f6rstorar hela inmatningsf\u00e4ltet *\/\r\n.checkbox-container input[type=\"number\"] {\r\n    width: 80px; \/* \u00d6ka bredden p\u00e5 f\u00e4ltet om det beh\u00f6vs *\/\r\n    font-size: 18px; \/* G\u00f6r texten st\u00f6rre *\/\r\n    height: 40px; \/* G\u00f6r f\u00e4ltet h\u00f6gre *\/\r\n    padding: 5px;\r\n}\r\n\/* Specifikt f\u00f6r spinn-knapparna *\/\r\ninput[type=\"number\"]::-webkit-inner-spin-button, \r\ninput[type=\"number\"]::-webkit-outer-spin-button {\r\n    transform: scale(1.5); \/* G\u00f6r knapparna st\u00f6rre *\/\r\n    margin: 0; \/* Tar bort extra marginal *\/\r\n}\r\n\r\n\r\n    <\/style>\r\n\r\n    <div class=\"custom-faskompensering\">\r\n        <div class=\"container\">\r\n            <h3>Faskompensering<\/h3>\r\n            <p>Ange data f\u00f6r dimensionering av kondensatorbatteri.<\/p>\r\n\r\n            <label for=\"unit\">V\u00e4lj enhet:<\/label>\r\n            <div class=\"input-container\">\r\n                <select id=\"unit\" onchange=\"updateUnitLabel()\">\r\n                    <option value=\"W\">W<\/option>\r\n                    <option value=\"kW\" selected>kW<\/option>\r\n                    <option value=\"MW\">MW<\/option>\r\n                <\/select>\r\n                <span id=\"unitError\" class=\"error-message\">V\u00e4lj en enhet.<\/span>\r\n            <\/div>\r\n\r\n            <label for=\"power\">Effekt (<span id=\"unitLabel\">kW<\/span>):<\/label>\r\n            <div class=\"input-container\">\r\n                <input type=\"number\" id=\"power\" placeholder=\"Ange effektv\u00e4rde\" oninput=\"calculate()\">\r\n                <span id=\"powerError\" class=\"error-message\">Effekt m\u00e5ste fyllas i och vara st\u00f6rre \u00e4n 0.<\/span>\r\n            <\/div>\r\n\r\n            <label for=\"voltage\">Sp\u00e4nning (V):<\/label>\r\n            <div class=\"input-container\">\r\n                <input type=\"number\" id=\"voltage\" placeholder=\"Ex: 400\" oninput=\"calculate()\">\r\n                <span id=\"voltageError\" class=\"error-message\">Sp\u00e4nning m\u00e5ste fyllas i och vara st\u00f6rre \u00e4n 0.<\/span>\r\n            <\/div>\r\n\r\n            <div class=\"row\">\r\n                <div>\r\n                    <label for=\"cosPhi1\">Nuvarande Cos \u03c6:<\/label>\r\n                    <div class=\"input-container\">\r\n                        <input type=\"number\" step=\"0.01\" id=\"cosPhi1\" placeholder=\"Ex: 0.75\" oninput=\"calculate()\">\r\n                        <span id=\"cosPhi1Error\" class=\"error-message\">V\u00e4rdet m\u00e5ste vara mellan 0 och 1.<\/span>\r\n                    <\/div>\r\n                <\/div>\r\n                <div class=\"current-field\">\r\n                    <label for=\"current\">Str\u00f6m (A):<\/label>\r\n                    <div class=\"input-container\">\r\n                        <input type=\"number\" id=\"current\" placeholder=\"Ber\u00e4knas automatiskt\" readonly>\r\n                    <\/div>\r\n                <\/div>\r\n            <\/div>\r\n\r\n            <label for=\"frequency\">Frekvens (Hz):<\/label>\r\n            <div class=\"input-container\">\r\n                <input type=\"number\" id=\"frequency\" value=\"50\" oninput=\"calculate()\">\r\n                <span id=\"frequencyError\" class=\"error-message\">Frekvens m\u00e5ste fyllas i och vara st\u00f6rre \u00e4n 0.<\/span>\r\n            <\/div>\r\n\r\n            <label for=\"cosPhi2\">\u00d6nskad Cos \u03c6:<\/label>\r\n            <div class=\"input-container\">\r\n                <input type=\"number\" step=\"0.01\" id=\"cosPhi2\" placeholder=\"Ex: 0.90\" oninput=\"calculate()\">\r\n                <span id=\"cosPhi2Error\" class=\"error-message\">V\u00e4rdet m\u00e5ste vara mellan 0 och 1.<\/span>\r\n            <\/div>\r\n\r\n<div class=\"checkbox-container\">\r\n    <input type=\"checkbox\" id=\"safetyMargin\" onchange=\"toggleSafetyMarginInput(); calculate()\">\r\n    <label for=\"safetyMargin\">Inkludera s\u00e4kerhetsmarginal<\/label>\r\n    <input \r\n        type=\"number\" \r\n        id=\"safetyMarginValue\" \r\n        value=\"10\" \r\n        min=\"0\" \r\n        max=\"20\" \r\n        step=\"0.1\" \r\n        oninput=\"calculate()\" \r\n        style=\"display: none; width: 65px; height: 35px; font-size: 16px; padding: 5px;\"\r\n    >\r\n    <span style=\"margin-left: -7px; line-height: 35px; font-size: 16px;\">%<\/span>\r\n<\/div>\r\n\r\n<div class=\"checkbox-container\">\r\n    <input type=\"checkbox\" id=\"includeTHD\" onchange=\"toggleTHDInput(); calculate()\">\r\n    <label for=\"includeTHD\"><\/label>\r\n    <input \r\n        type=\"number\" \r\n        id=\"thdValue\" \r\n        value=\"0\" \r\n        min=\"0\" \r\n        max=\"0\" \r\n        step=\"0.1\" \r\n        oninput=\"calculate()\" \r\n        style=\"display: none; width: 65px; height: 35px; font-size: 16px; padding: 5px;\"\r\n    >\r\n    <span style=\"margin-left: -7px; line-height: 35px; font-size: 16px;\"><\/span>\r\n<\/div>\r\n\r\n\r\n\r\n\r\n\r\n            <div id=\"results\" class=\"results\" style=\"display: none; margin-bottom: 0;\">\r\n                <h2>Resultat<\/h2>\r\n                <p id=\"resultText\"><\/p>\r\n                <div class=\"unit-circle-container\">\r\n                    <div class=\"unit-circle-container\">\r\n    <canvas id=\"unitCircleCanvas\" width=\"500\" height=\"500\"><\/canvas>\r\n<\/div>\r\n<p style=\"font-size: 12px; text-align: left;\"> <strong>Notering:<\/strong> Dessa ber\u00e4kningar f\u00f6ruts\u00e4tter en ideal trefaskrets och tar inte h\u00e4nsyn till verkliga f\u00f6rh\u00e5llanden som kan p\u00e5verka systemets prestanda. Faktorer s\u00e5som harmoniska, fasobalans, sp\u00e4nningsfall, reaktiv effekt, temperaturvariationer och kabelresistans kan alla p\u00e5verka resultatet. F\u00f6r att s\u00e4kerst\u00e4lla korrekt dimensionering och en s\u00e4ker installation rekommenderas det starkt att konsultera en beh\u00f6rig elkraftingenj\u00f6r eller elektriker med relevant erfarenhet. <\/p>\r\n\r\n                <\/div>\r\n            <\/div>\r\n        <\/div>\r\n    <\/div>\r\n \r\n \r\n \r\n <center>\r\n\r\n<div style=\"margin-left: 38px; font-size: 16px; line-height: 1.8;\">\r\n    <a href=\"https:\/\/hintek.se\/index.php\/faskompensering2\/\" \r\n       class=\"policy-link\"\r\n       aria-label=\"L\u00e4nk till hur formeln fungerar\">\r\n        S\u00e5 fungerar formeln\r\n    <\/a>\r\n<\/div>\r\n\r\n<style>\r\n    \/* CSS som endast p\u00e5verkar l\u00e4nken med klassen policy-link *\/\r\n    .policy-link {\r\n        color: #113351; \/* Startf\u00e4rg f\u00f6r l\u00e4nken *\/\r\n        text-decoration: none !important; \/* Ingen understrykning *\/\r\n        font-weight: normal;\r\n    }\r\n\r\n    .policy-link:hover {\r\n        animation: blink 0.8s infinite alternate; \/* Blinkande animation vid hover *\/\r\n    }\r\n\r\n    @keyframes blink {\r\n        0% {\r\n            color: #113351;\r\n        }\r\n        100% {\r\n            color: #6A9FB5;\r\n        }\r\n    }\r\n<\/style>\r\n\r\n\r\n\r\n<\/center>\r\n \r\n \r\n \r\n \r\n \r\n    <script>\r\n        \/\/ Funktion f\u00f6r att ers\u00e4tta komma med punkt\r\n        function sanitizeNumber(input) {\r\n            if (typeof input === 'string') {\r\n                return input.replace(',', '.');\r\n            }\r\n            return input;\r\n        }\r\n\r\n        const unitCircleCanvas = document.getElementById(\"unitCircleCanvas\");\r\n        const unitCtx = unitCircleCanvas.getContext(\"2d\");\r\n\r\n        const center = { x: unitCircleCanvas.width \/ 2, y: unitCircleCanvas.height \/ 2 };\r\n        const radius = 200; \/\/ Radie f\u00f6r enhetscirkeln\r\n\r\n        function drawUnitCircle() {\r\n            \/\/ Rensa canvasen\r\n            unitCtx.clearRect(0, 0, unitCircleCanvas.width, unitCircleCanvas.height);\r\n\r\n            \/\/ Rita enhetscirkeln\r\n            unitCtx.beginPath();\r\n            unitCtx.arc(center.x, center.y, radius, 0, 2 * Math.PI);\r\n            unitCtx.strokeStyle = \"gray\";\r\n            unitCtx.lineWidth = 1;\r\n            unitCtx.stroke();\r\n\r\n            \/\/ Rita rutn\u00e4tet\r\n            unitCtx.beginPath();\r\n            for (let i = 0; i <= 10; i++) {\r\n                unitCtx.moveTo(center.x - radius, center.y - radius + (i * 2 * radius) \/ 10);\r\n                unitCtx.lineTo(center.x + radius, center.y - radius + (i * 2 * radius) \/ 10);\r\n                unitCtx.moveTo(center.x - radius + (i * 2 * radius) \/ 10, center.y - radius);\r\n                unitCtx.lineTo(center.x - radius + (i * 2 * radius) \/ 10, center.y + radius);\r\n            }\r\n            unitCtx.strokeStyle = \"#ddd\";\r\n            unitCtx.lineWidth = 0.5;\r\n            unitCtx.stroke();\r\n\r\n            \/\/ Rita x- och y-axlarna (de svarta linjerna)\r\n            unitCtx.beginPath();\r\n            unitCtx.moveTo(center.x - radius, center.y);  \/\/ V\u00e4nstra horisontella linjen\r\n            unitCtx.lineTo(center.x + radius, center.y);  \/\/ H\u00f6ger horisontell linje\r\n            unitCtx.moveTo(center.x, center.y - radius);  \/\/ \u00d6vre vertikala linjen\r\n            unitCtx.lineTo(center.x, center.y + radius);  \/\/ Nedre vertikala linjen\r\n            unitCtx.strokeStyle = \"black\";\r\n            unitCtx.lineWidth = 2;\r\n            unitCtx.stroke();\r\n        }\r\n\r\n        function drawArrow(fromX, fromY, toX, toY, color, label) {\r\n            const headLength = 10; \/\/ L\u00e4ngd p\u00e5 pilhuvudet\r\n            const dx = toX - fromX;\r\n            const dy = toY - fromY;\r\n            const angle = Math.atan2(dy, dx);\r\n\r\n            \/\/ Rita linjen\r\n            unitCtx.beginPath();\r\n            unitCtx.moveTo(fromX, fromY);\r\n            unitCtx.lineTo(toX, toY);\r\n            unitCtx.strokeStyle = color;\r\n            unitCtx.lineWidth = 2;\r\n            unitCtx.stroke();\r\n\r\n            \/\/ Rita pilhuvudet\r\n            unitCtx.beginPath();\r\n            unitCtx.moveTo(toX, toY);\r\n            unitCtx.lineTo(\r\n                toX - headLength * Math.cos(angle - Math.PI \/ 6),\r\n                toY - headLength * Math.sin(angle - Math.PI \/ 6)\r\n            );\r\n            unitCtx.lineTo(\r\n                toX - headLength * Math.cos(angle + Math.PI \/ 6),\r\n                toY - headLength * Math.sin(angle + Math.PI \/ 6)\r\n            );\r\n            unitCtx.lineTo(toX, toY);\r\n            unitCtx.fillStyle = color;\r\n            unitCtx.fill();\r\n\r\n            \/\/ L\u00e4gg till etiketten\r\n            unitCtx.save();\r\n            unitCtx.font = \"12px Arial\";\r\n            const labelOffsetFactor = 0.2; \/\/ Justera denna faktor f\u00f6r att styra etikettens position l\u00e4ngs pilen\r\n            unitCtx.translate(fromX + dx * labelOffsetFactor, fromY + dy * labelOffsetFactor);\r\n            unitCtx.rotate(angle);\r\n            unitCtx.fillStyle = color;\r\n            unitCtx.fillText(label, 0, -7); \/\/ Justera y-offset (-7) f\u00f6r att positionera etiketten ovanf\u00f6r linjen\r\n            unitCtx.restore();\r\n        }\r\n\r\n        function drawArrows(cosPhi1, cosPhi2, unit) {\r\n            \/\/ Ber\u00e4kna vinklar baserat p\u00e5 anv\u00e4ndarens inmatningar\r\n            const phi1 = Math.acos(cosPhi1);\r\n            const phi2 = Math.acos(cosPhi2);\r\n\r\n            \/\/ Ber\u00e4kna slutpunkter f\u00f6r pilarna\r\n            const endX1 = center.x + radius * cosPhi1;\r\n            const endY1 = center.y - radius * Math.sin(phi1);\r\n            const endX2 = center.x + radius * cosPhi2;\r\n            const endY2 = center.y - radius * Math.sin(phi2);\r\n\r\n            \/\/ Rita pilar med etiketter\r\n            drawArrow(center.x, center.y, endX1, endY1, \"red\", `Q1 (\u03c6: ${(phi1 * 180 \/ Math.PI).toFixed(1)}\u00b0, Cos \u03c6: ${cosPhi1.toFixed(2)})`);\r\n            drawArrow(center.x, center.y, endX2, endY2, \"green\", `Q2 (\u03c6: ${(phi2 * 180 \/ Math.PI).toFixed(1)}\u00b0, Cos \u03c6: ${cosPhi2.toFixed(2)})`);\r\n        }\r\n\r\n        function updateUnitLabel() {\r\n            const unit = document.getElementById(\"unit\").value;\r\n            document.getElementById(\"unitLabel\").innerText = unit;\r\n            calculate(); \/\/ Uppdatera ber\u00e4kningarna n\u00e4r enheten \u00e4ndras\r\n        }\r\n\r\n        function updateCurrent(voltage, cosPhi1, power, unit) {\r\n            if (!isNaN(voltage) && !isNaN(cosPhi1) && !isNaN(power) && cosPhi1 > 0 && cosPhi1 <= 1) {\r\n                const powerInW = convertToW(power, unit);\r\n                const sqrt3 = Math.sqrt(3);\r\n                const current = powerInW \/ (voltage * cosPhi1 * sqrt3);\r\n                document.getElementById(\"current\").value = current.toFixed(2);\r\n            } else {\r\n                document.getElementById(\"current\").value = \"\";\r\n            }\r\n        }\r\n\r\n        function convertToW(value, unit) {\r\n            if (unit === \"kW\") return value * 1000;\r\n            if (unit === \"MW\") return value * 1000000;\r\n            return value;\r\n        }\r\n\r\n        function calculate() {\r\n            const voltageInput = document.getElementById(\"voltage\").value;\r\n            const frequencyInput = document.getElementById(\"frequency\").value;\r\n            const cosPhi1Input = document.getElementById(\"cosPhi1\").value;\r\n            const cosPhi2Input = document.getElementById(\"cosPhi2\").value;\r\n            const powerInput = document.getElementById(\"power\").value;\r\n            const unit = document.getElementById(\"unit\").value;\r\n\r\n            \/\/ H\u00e4mta v\u00e4rden f\u00f6r s\u00e4kerhetsmarginal och THD\r\n            let safetyMarginPercentage = 0;\r\n            if (document.getElementById(\"safetyMargin\").checked) {\r\n                safetyMarginPercentage = parseFloat(document.getElementById(\"safetyMarginValue\").value) || 0;\r\n            }\r\n\r\n            let thdPercentage = 0;\r\n            if (document.getElementById(\"includeTHD\").checked) {\r\n                thdPercentage = parseFloat(document.getElementById(\"thdValue\").value) || 0;\r\n            }\r\n\r\n            \/\/ Sanitize inputs\r\n            const voltage = parseFloat(sanitizeNumber(voltageInput));\r\n            const frequency = parseFloat(sanitizeNumber(frequencyInput));\r\n            const cosPhi1 = parseFloat(sanitizeNumber(cosPhi1Input));\r\n            const cosPhi2 = parseFloat(sanitizeNumber(cosPhi2Input));\r\n            const power = parseFloat(sanitizeNumber(powerInput));\r\n\r\n            \/\/ Felmeddelanden\r\n            let hasError = false;\r\n\r\n            \/\/ Kontrollera om n\u00e5gra f\u00e4lt \u00e4r tomma innan du utf\u00f6r validering\r\n            if (voltageInput === \"\") {\r\n                showError(\"voltageError\");\r\n                hasError = true;\r\n            } else {\r\n                hideError(\"voltageError\");\r\n            }\r\n\r\n            if (frequencyInput === \"\") {\r\n                showError(\"frequencyError\");\r\n                hasError = true;\r\n            } else {\r\n                hideError(\"frequencyError\");\r\n            }\r\n\r\n            if (cosPhi1Input === \"\") {\r\n                showError(\"cosPhi1Error\");\r\n                hasError = true;\r\n            } else {\r\n                hideError(\"cosPhi1Error\");\r\n            }\r\n\r\n            if (cosPhi2Input === \"\") {\r\n                showError(\"cosPhi2Error\");\r\n                hasError = true;\r\n            } else {\r\n                hideError(\"cosPhi2Error\");\r\n            }\r\n\r\n            if (powerInput === \"\") {\r\n                showError(\"powerError\");\r\n                hasError = true;\r\n            } else {\r\n                hideError(\"powerError\");\r\n            }\r\n\r\n            if (hasError) {\r\n                document.getElementById(\"results\").style.display = \"none\";\r\n                document.getElementById(\"current\").value = \"\";\r\n                return;\r\n            }\r\n\r\n            \/\/ F\u00f6rb\u00e4ttrad validering\r\n            if (isNaN(voltage) || voltage <= 0) {\r\n                showError(\"voltageError\");\r\n                hasError = true;\r\n            } else {\r\n                hideError(\"voltageError\");\r\n            }\r\n\r\n            if (isNaN(frequency) || frequency <= 0) {\r\n                showError(\"frequencyError\");\r\n                hasError = true;\r\n            } else {\r\n                hideError(\"frequencyError\");\r\n            }\r\n\r\n            if (isNaN(cosPhi1) || cosPhi1 < 0 || cosPhi1 > 1) {\r\n                showError(\"cosPhi1Error\");\r\n                hasError = true;\r\n            } else {\r\n                hideError(\"cosPhi1Error\");\r\n            }\r\n\r\n            if (isNaN(cosPhi2) || cosPhi2 < 0 || cosPhi2 > 1) {\r\n                showError(\"cosPhi2Error\");\r\n                hasError = true;\r\n            } else {\r\n                hideError(\"cosPhi2Error\");\r\n            }\r\n\r\n            if (isNaN(power) || power <= 0) {\r\n                showError(\"powerError\");\r\n                hasError = true;\r\n            } else {\r\n                hideError(\"powerError\");\r\n            }\r\n\r\n            if (hasError) {\r\n                document.getElementById(\"results\").style.display = \"none\";\r\n                document.getElementById(\"current\").value = \"\";\r\n                return;\r\n            }\r\n\r\n            \/\/ Ber\u00e4kningar\r\n            const powerInW = convertToW(power, unit);\r\n            const phi1 = Math.acos(cosPhi1);\r\n            const phi2 = Math.acos(cosPhi2);\r\n            const Q1 = powerInW * Math.tan(phi1);\r\n            const Q2 = powerInW * Math.tan(phi2);\r\n            const Qc = Q1 - Q2;\r\n\r\n            \/\/ Kontrollera att procentsatserna \u00e4r inom intervallet 0-20%\r\n            if (safetyMarginPercentage < 0 || safetyMarginPercentage > 20) {\r\n                safetyMarginPercentage = 0;\r\n            }\r\n\r\n            if (thdPercentage < 0 || thdPercentage > 20) {\r\n                thdPercentage = 0;\r\n            }\r\n\r\n            \/\/ Ber\u00e4kna den totala justeringsfaktorn\r\n            const totalAdjustmentFactor = 1 + safetyMarginPercentage \/ 100 + thdPercentage \/ 100;\r\n\r\n            \/\/ Korrigera Qc med total justeringsfaktor\r\n            const correctedQc = Qc * totalAdjustmentFactor;\r\n\r\n            \/\/ F\u00f6r visning i r\u00e4tt enhet\r\n            let QcUnit;\r\n            let QcDisplay;\r\n            let correctedQcDisplay;\r\n            if (unit === \"W\") {\r\n                QcUnit = \"VAr\";\r\n                QcDisplay = Qc;\r\n                correctedQcDisplay = correctedQc;\r\n            } else if (unit === \"kW\") {\r\n                QcUnit = \"kVAr\";\r\n                QcDisplay = Qc \/ 1000;\r\n                correctedQcDisplay = correctedQc \/ 1000;\r\n            } else if (unit === \"MW\") {\r\n                QcUnit = \"MVAr\";\r\n                QcDisplay = Qc \/ 1e6;\r\n                correctedQcDisplay = correctedQc \/ 1e6;\r\n            }\r\n\r\n            \/\/ Ber\u00e4kna kapacitansen med korrigerat Qc\r\n            const C = correctedQc \/ (2 * Math.PI * frequency * Math.pow(voltage, 2));\r\n\r\n            \/\/ Konvertera kapacitans till olika enheter\r\n            const capacitanceInMicrofarad = C * 1e6;\r\n            const capacitanceInMillifarad = C * 1e3;\r\n            const capacitanceInFarad = C;\r\n\r\n            \/\/ Uppdatera str\u00f6mv\u00e4rdet\r\n            updateCurrent(voltage, cosPhi1, power, unit);\r\n\r\n            const resultDiv = document.getElementById(\"results\");\r\n            const resultText = document.getElementById(\"resultText\");\r\n            resultDiv.style.display = \"block\";\r\n\r\n            \/\/ Formatera resultat baserat p\u00e5 enheten\r\n            const formattedP = formatNumber(powerInW \/ (unit === \"W\" ? 1 : unit === \"kW\" ? 1000 : 1000000));\r\n            const formattedQ1 = formatNumber(Q1 \/ (unit === \"W\" ? 1 : unit === \"kW\" ? 1000 : 1000000));\r\n            const formattedQ2 = formatNumber(Q2 \/ (unit === \"W\" ? 1 : unit === \"kW\" ? 1000 : 1000000));\r\n            const formattedQc = formatNumber(QcDisplay);\r\n            const formattedC_\u00b5F = formatNumber(capacitanceInMicrofarad);\r\n            const formattedC_mF = formatNumber(capacitanceInMillifarad);\r\n            const formattedC_F = formatNumber(capacitanceInFarad, 4);\r\n\r\n            let resultHTML = `\r\n                <strong>Aktiv effekt (P):<\/strong> ${formattedP} ${unit}<br>\r\n                <strong>Reaktiv effekt f\u00f6re (Q1):<\/strong> ${formattedQ1} ${QcUnit}<br>\r\n                <strong>Reaktiv effekt efter (Q2):<\/strong> ${formattedQ2} ${QcUnit}<br>\r\n                <strong>Kapacitans (C):<\/strong><br>\r\n                ${formattedC_\u00b5F} \u00b5F<br>\r\n                ${formattedC_mF} mF<br>\r\n                ${formattedC_F} F<br>\r\n\r\n            `;\r\n\r\n            resultHTML += `<strong>F\u00f6rslag p\u00e5 kondensatorbatteri (korrigerat):<\/strong> ${formatNumber(correctedQcDisplay)} ${QcUnit}<br>`;\r\n\r\n            if (safetyMarginPercentage > 0) {\r\n                resultHTML += `<strong>S\u00e4kerhetsmarginal:<\/strong> ${safetyMarginPercentage.toFixed(1)}%<br>`;\r\n            }\r\n\r\n            if (thdPercentage > 0) {\r\n                resultHTML += `<strong>Total Harmonic Distortion (THD):<\/strong> ${thdPercentage.toFixed(1)}%<br>`;\r\n            }\r\n\r\n            resultText.innerHTML = resultHTML;\r\n\r\n            \/\/ Rita enhetscirkeln och pilarna med de aktuella cos\u03a6 v\u00e4rdena\r\n            drawUnitCircle();\r\n            drawArrows(cosPhi1, cosPhi2, unit);\r\n        }\r\n\r\n        \/\/ Funktion f\u00f6r att visa\/d\u00f6lja inmatningsf\u00e4ltet f\u00f6r s\u00e4kerhetsmarginal\r\n        function toggleSafetyMarginInput() {\r\n            const safetyMarginInput = document.getElementById(\"safetyMarginValue\");\r\n            if (document.getElementById(\"safetyMargin\").checked) {\r\n                safetyMarginInput.style.display = \"inline-block\";\r\n            } else {\r\n                safetyMarginInput.style.display = \"none\";\r\n            }\r\n            calculate();\r\n        }\r\n\r\n        \/\/ Funktion f\u00f6r att visa\/d\u00f6lja inmatningsf\u00e4ltet f\u00f6r THD\r\n        function toggleTHDInput() {\r\n            const thdInput = document.getElementById(\"thdValue\");\r\n            if (document.getElementById(\"includeTHD\").checked) {\r\n                thdInput.style.display = \"inline-block\";\r\n            } else {\r\n                thdInput.style.display = \"none\";\r\n            }\r\n            calculate();\r\n        }\r\n\r\n        \/\/ Visa felmeddelande\r\n        function showError(elementId) {\r\n            const errorElement = document.getElementById(elementId);\r\n            const inputElement = errorElement.previousElementSibling;\r\n            errorElement.style.display = \"block\";\r\n            inputElement.classList.add(\"input-error\");\r\n        }\r\n\r\n        \/\/ D\u00f6lj felmeddelande\r\n        function hideError(elementId) {\r\n            const errorElement = document.getElementById(elementId);\r\n            const inputElement = errorElement.previousElementSibling;\r\n            errorElement.style.display = \"none\";\r\n            inputElement.classList.remove(\"input-error\");\r\n        }\r\n\r\n        \/\/ Formatera tal baserat p\u00e5 enheten och decimalseparator\r\n        function formatNumber(num, decimals = 2) {\r\n            return num.toLocaleString('sv-SE', { minimumFractionDigits: decimals, maximumFractionDigits: decimals });\r\n        }\r\n\r\n        \/\/ Initial Setup\r\n        document.getElementById(\"unit\").addEventListener(\"change\", updateUnitLabel);\r\n        document.getElementById(\"power\").addEventListener(\"input\", calculate);\r\n        document.getElementById(\"voltage\").addEventListener(\"input\", calculate);\r\n        document.getElementById(\"cosPhi1\").addEventListener(\"input\", calculate);\r\n        document.getElementById(\"cosPhi2\").addEventListener(\"input\", calculate);\r\n        document.getElementById(\"frequency\").addEventListener(\"input\", calculate);\r\n        document.getElementById(\"safetyMargin\").addEventListener(\"change\", toggleSafetyMarginInput);\r\n        document.getElementById(\"includeTHD\").addEventListener(\"change\", toggleTHDInput);\r\n        document.getElementById(\"safetyMarginValue\").addEventListener(\"input\", calculate);\r\n        document.getElementById(\"thdValue\").addEventListener(\"input\", calculate);\r\n\r\n        \/\/ Initialisera inmatningsf\u00e4lten vid sidladdning\r\n        window.onload = function() {\r\n            toggleSafetyMarginInput();\r\n            toggleTHDInput();\r\n            drawUnitCircle();\r\n        };\r\n    <\/script>\r\n\r\n\r\n\r\n\r\n<\/html>\r\n\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Version 1<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"disabled","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"class_list":["post-757","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/hintek.se\/index.php\/wp-json\/wp\/v2\/pages\/757","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hintek.se\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/hintek.se\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/hintek.se\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/hintek.se\/index.php\/wp-json\/wp\/v2\/comments?post=757"}],"version-history":[{"count":99,"href":"https:\/\/hintek.se\/index.php\/wp-json\/wp\/v2\/pages\/757\/revisions"}],"predecessor-version":[{"id":1186,"href":"https:\/\/hintek.se\/index.php\/wp-json\/wp\/v2\/pages\/757\/revisions\/1186"}],"wp:attachment":[{"href":"https:\/\/hintek.se\/index.php\/wp-json\/wp\/v2\/media?parent=757"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}