Last active
May 17, 2025 13:33
-
-
Save thuliumsystems/476e4fa126cd9f2ba5dee4d42da8a522 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "cells": [ | |
| { | |
| "cell_type": "code", | |
| "execution_count": 7, | |
| "id": "4736251f", | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "name": "stdout", | |
| "output_type": "stream", | |
| "text": [ | |
| "--- Load and Voltage Drop Analysis ---\n", | |
| "\n", | |
| "--- Load Details ---\n", | |
| "---------------------------------------------\n", | |
| "item | KW | 1ϕ I (A) | 3ϕ I (A) \n", | |
| "---------------------------------------------\n", | |
| "1 | 0.345 | 2.875 | 0.000 \n", | |
| "2 | 2.797 | 0.000 | 14.500 \n", | |
| "3 | 1.000 | 8.333 | 0.000 \n", | |
| "4 | 8.952 | 0.000 | 17.200 \n", | |
| "totals | 13.095 | 11.208 | 31.700 \n", | |
| "---------------------------------------------\n", | |
| "\n", | |
| "--- Calculation Summary ---\n", | |
| "Total KW: 13.095\n", | |
| "Total 1ϕ I: 11.208\n", | |
| "Total 3ϕ I: 31.700\n", | |
| "I/ϕ: 35.436\n", | |
| "------------------------------\n", | |
| "Required CM (VD=5V): 7917.419\n", | |
| "\n", | |
| "AWG vs CM Lookup Table Reference:\n", | |
| "AWG | CM\n", | |
| "----|------\n", | |
| "14 | 4110 \n", | |
| "12 | 6530 \n", | |
| "10 | 10380\n", | |
| "8 | 16520\n", | |
| "6 | 26240\n", | |
| "4 | 41740\n", | |
| "2 | 66360\n", | |
| "1 | 83690\n", | |
| "----|------\n", | |
| "\n", | |
| "Selected AWG (CS): AWG 10 (10380 CM)\n", | |
| "AVD: 3.814 V\n", | |
| "MAVD (for 208V): 10.400 V\n", | |
| "------------------------------\n", | |
| "STATUS: AVD <= MAVD - Voltage Drop OK!\n", | |
| "\n", | |
| "--- Current Analysis ---\n", | |
| "MIN I/ϕ (-10%): 31.892 A\n", | |
| "MAX I/ϕ (+10%): 38.980 A\n", | |
| "------------------------------\n" | |
| ] | |
| } | |
| ], | |
| "source": [ | |
| "from math import ceil\n", | |
| "\n", | |
| "K = 12.9\n", | |
| "distance_feet = 50\n", | |
| "target_voltage_drop_for_cm = 5\n", | |
| "\n", | |
| "awg_cm_lookup = {\n", | |
| " 14: 4110,\n", | |
| " 12: 6530,\n", | |
| " 10: 10380,\n", | |
| " 8: 16520,\n", | |
| " 6: 26240,\n", | |
| " 4: 41740,\n", | |
| " 2: 66360,\n", | |
| " 1: 83690,\n", | |
| "}\n", | |
| "\n", | |
| "mavd_lookup = {\n", | |
| " 120: 6,\n", | |
| " 208: 10.4,\n", | |
| " 240: 12,\n", | |
| " 416: 20.8,\n", | |
| "}\n", | |
| "\n", | |
| "loads_list = [\n", | |
| " {\"item\": 1, \"qty\": 3, \"type\": \"resistive\", \"P\": 115, \"V\": 120, \"phases\": 1},\n", | |
| " {\"item\": 2, \"qty\": 5, \"type\": \"inductive\", \"HP\": 0.75, \"I\": 2.9, \"V\": 208, \"phases\": 3},\n", | |
| " {\"item\": 3, \"qty\": 5, \"type\": \"resistive\", \"P\": 200, \"V\": 120, \"phases\": 1},\n", | |
| " {\"item\": 4, \"qty\": 4, \"type\": \"inductive\", \"HP\": 3, \"I\": 4.3, \"V\": 208, \"phases\": 3},\n", | |
| "]\n", | |
| "\n", | |
| "total_kw = 0\n", | |
| "total_1phi_I = 0\n", | |
| "total_3phi_I = 0\n", | |
| "load_summary_data = []\n", | |
| "system_is_3phi = False\n", | |
| "\n", | |
| "for load in loads_list:\n", | |
| " kw = one_phi_I = three_phi_I = 0\n", | |
| "\n", | |
| " if load[\"type\"] == \"resistive\":\n", | |
| " kw = load[\"qty\"] * load[\"P\"] / 1000\n", | |
| " one_phi_I = load[\"qty\"] * load[\"P\"] / load[\"V\"]\n", | |
| "\n", | |
| " elif load[\"type\"] == \"inductive\":\n", | |
| " kw = load[\"qty\"] * load[\"HP\"] * 0.746\n", | |
| " three_phi_I = load[\"qty\"] * load[\"I\"]\n", | |
| "\n", | |
| " total_kw += kw\n", | |
| " total_1phi_I += one_phi_I\n", | |
| " total_3phi_I += three_phi_I\n", | |
| "\n", | |
| " load_summary_data.append((\n", | |
| " load[\"item\"],\n", | |
| " round(kw, 3),\n", | |
| " round(one_phi_I, 3) if one_phi_I > 0 else 0,\n", | |
| " round(three_phi_I, 3) if three_phi_I > 0 else 0\n", | |
| " ))\n", | |
| "\n", | |
| " if load[\"phases\"] == 3:\n", | |
| " system_is_3phi = True\n", | |
| "\n", | |
| "load_summary_data.append((\"totals\", round(total_kw, 3), round(total_1phi_I, 3), round(total_3phi_I, 3)))\n", | |
| "\n", | |
| "system_voltage = 208\n", | |
| "\n", | |
| "i_per_phi = total_1phi_I / 3 + total_3phi_I\n", | |
| "\n", | |
| "if system_is_3phi:\n", | |
| " cm_required = (1.732 * K * i_per_phi * distance_feet) / target_voltage_drop_for_cm\n", | |
| "\n", | |
| " awg_selected = None\n", | |
| " awg_cm_selected = None\n", | |
| " sorted_awg_table = sorted(awg_cm_lookup.items(), key=lambda item: item[1])\n", | |
| " for awg, cm in sorted_awg_table:\n", | |
| " if cm >= cm_required:\n", | |
| " awg_selected = awg\n", | |
| " awg_cm_selected = cm\n", | |
| " break\n", | |
| "\n", | |
| " if awg_selected is not None:\n", | |
| " avd = (1.732 * K * i_per_phi * distance_feet) / awg_cm_selected\n", | |
| " else:\n", | |
| " avd = float('inf')\n", | |
| "\n", | |
| " mavd = mavd_lookup.get(system_voltage, None)\n", | |
| "\n", | |
| "else:\n", | |
| " cm_required = (2 * K * i_per_phi * distance_feet) / target_voltage_drop_for_cm\n", | |
| "\n", | |
| " awg_selected = None\n", | |
| " awg_cm_selected = None\n", | |
| " sorted_awg_table = sorted(awg_cm_lookup.items(), key=lambda item: item[1])\n", | |
| " for awg, cm in sorted_awg_table:\n", | |
| " if cm >= cm_required:\n", | |
| " awg_selected = awg\n", | |
| " awg_cm_selected = cm\n", | |
| " break\n", | |
| "\n", | |
| " if awg_selected is not None:\n", | |
| " avd = (2 * K * i_per_phi * distance_feet) / awg_cm_selected\n", | |
| " else:\n", | |
| " avd = float('inf')\n", | |
| "\n", | |
| " mavd = mavd_lookup.get(system_voltage, None)\n", | |
| "\n", | |
| "min_i_per_phi = i_per_phi * 0.9\n", | |
| "max_i_per_phi = i_per_phi * 1.1\n", | |
| "\n", | |
| "print(\"--- Load and Voltage Drop Analysis ---\")\n", | |
| "\n", | |
| "print(\"\\n--- Load Details ---\")\n", | |
| "print(\"-\" * 45)\n", | |
| "print(f\"{'item':<5} | {'KW':<8} | {'1ϕ I (A)':<10} | {'3ϕ I (A)':<10}\")\n", | |
| "print(\"-\" * 45)\n", | |
| "\n", | |
| "for row in load_summary_data:\n", | |
| " print(f\"{str(row[0]):<5} | {row[1]:<8.3f} | {row[2]:<10.3f} | {row[3]:<10.3f}\")\n", | |
| "\n", | |
| "print(\"-\" * 45)\n", | |
| "\n", | |
| "print(\"\\n--- Calculation Summary ---\")\n", | |
| "\n", | |
| "print(f\"{'Total KW:':<20} {total_kw:.3f}\")\n", | |
| "print(f\"{'Total 1ϕ I:':<20} {total_1phi_I:.3f}\")\n", | |
| "print(f\"{'Total 3ϕ I:':<20} {total_3phi_I:.3f}\")\n", | |
| "print(f\"{'I/ϕ:':<20} {i_per_phi:.3f}\")\n", | |
| "print(\"-\" * 30)\n", | |
| "print(f\"{'Required CM (VD=' + str(target_voltage_drop_for_cm) + 'V):':<20} {cm_required:.3f}\")\n", | |
| "\n", | |
| "print(\"\\nAWG vs CM Lookup Table Reference:\")\n", | |
| "print(\"AWG | CM\")\n", | |
| "print(\"----|------\")\n", | |
| "for awg, cm in awg_cm_lookup.items():\n", | |
| " print(f\"{awg:<3} | {cm:<5}\")\n", | |
| "print(\"----|------\")\n", | |
| "\n", | |
| "if awg_selected is not None and awg_cm_selected is not None:\n", | |
| " print(f\"\\n{'Selected AWG (CS):':<20} AWG {awg_selected} ({awg_cm_selected} CM)\")\n", | |
| " print(f\"{'AVD:':<20} {avd:.3f} V\")\n", | |
| " if mavd is not None:\n", | |
| " print(f\"{'MAVD (for ' + str(system_voltage) + 'V):':<20} {mavd:.3f} V\")\n", | |
| " print(\"-\" * 30)\n", | |
| " if avd <= mavd:\n", | |
| " print(\"STATUS: AVD <= MAVD - Voltage Drop OK!\")\n", | |
| " else:\n", | |
| " print(\"STATUS: AVD > MAVD - Voltage Drop EXCEEDED! Consider a larger AWG.\")\n", | |
| " else:\n", | |
| " print(f\"{'MAVD:':<20} N/A (System voltage not found in lookup)\")\n", | |
| " print(\"\\nNOTE: MAVD not defined for this voltage. Unable to compare AVD vs MAVD.\")\n", | |
| "\n", | |
| "else:\n", | |
| " print(f\"\\n{'Selected AWG (CS):':<20} None in Table\")\n", | |
| " print(f\"{'AVD:':<20} N/A (Required CM too high or AWG not found)\")\n", | |
| " if mavd is not None:\n", | |
| " print(f\"{'MAVD (for ' + str(system_voltage) + 'V):':<20} {mavd:.3f} V\")\n", | |
| " else:\n", | |
| " print(f\"{'MAVD:':<20} N/A (System voltage not found in lookup)\")\n", | |
| " print(\"\\nSTATUS: Required CM too high. Add larger AWGs to 'awg_cm_lookup' table or revise load/distance.\")\n", | |
| "\n", | |
| "print(\"\\n--- Current Analysis ---\")\n", | |
| "print(f\"{'MIN I/ϕ (-10%):':<20} {min_i_per_phi:.3f} A\")\n", | |
| "print(f\"{'MAX I/ϕ (+10%):':<20} {max_i_per_phi:.3f} A\")\n", | |
| "print(\"-\" * 30)" | |
| ] | |
| } | |
| ], | |
| "metadata": { | |
| "kernelspec": { | |
| "display_name": "Python 3", | |
| "language": "python", | |
| "name": "python3" | |
| }, | |
| "language_info": { | |
| "codemirror_mode": { | |
| "name": "ipython", | |
| "version": 3 | |
| }, | |
| "file_extension": ".py", | |
| "mimetype": "text/x-python", | |
| "name": "python", | |
| "nbconvert_exporter": "python", | |
| "pygments_lexer": "ipython3", | |
| "version": "3.9.6" | |
| } | |
| }, | |
| "nbformat": 4, | |
| "nbformat_minor": 5 | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment