From 97d1f4e58c31ffac200fe8f9357f237944a4e152 Mon Sep 17 00:00:00 2001 From: Jeff MacKinnon Date: Thu, 19 Dec 2024 10:08:46 -0400 Subject: [PATCH] Updated examples with new functionality --- example_notebook.ipynb | 455 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 439 insertions(+), 16 deletions(-) diff --git a/example_notebook.ipynb b/example_notebook.ipynb index 2a0e3bd..0df9f91 100644 --- a/example_notebook.ipynb +++ b/example_notebook.ipynb @@ -37,7 +37,7 @@ "source": [ "## Voltage Drop\n", "\n", - "The function voltage_drop returns the total ``voltage drop`` and the ``percentage`` from nominal." + "The function voltage_drop returns the total ``voltage drop`` and the ``percentage`` from nominal. The variables are, in order, `voltage`, `current`, `conductor size`, `length`." ] }, { @@ -48,7 +48,7 @@ { "data": { "text/plain": [ - "[24.96, 10.4]" + "[15.6, 6.5]" ] }, "execution_count": 2, @@ -57,7 +57,7 @@ } ], "source": [ - "jmk.voltage_drop(240, 100, '2/0')" + "jmk.voltage_drop(240, 100, '2/0',150)" ] }, { @@ -75,7 +75,7 @@ { "data": { "text/plain": [ - "[12.96, 5.4]" + "[8.1, 3.3749999999999996]" ] }, "execution_count": 3, @@ -84,7 +84,7 @@ } ], "source": [ - "jmk.voltage_drop(240, 100, '2/0', material='al')" + "jmk.voltage_drop(240, 100, '2/0', 150,material='al')" ] }, { @@ -102,7 +102,7 @@ { "data": { "text/plain": [ - "[3.24, 1.35]" + "[2.025, 0.8437499999999999]" ] }, "execution_count": 4, @@ -111,7 +111,7 @@ } ], "source": [ - "jmk.voltage_drop(240, 100, '2/0', material='al', num_runs=4)" + "jmk.voltage_drop(240, 100, '2/0', 150,material='al', num_runs=4)" ] }, { @@ -166,7 +166,7 @@ { "data": { "text/plain": [ - "[350, 2]" + "['350', 2]" ] }, "execution_count": 6, @@ -186,7 +186,7 @@ { "data": { "text/plain": [ - "[400, 3]" + "['400', 3]" ] }, "execution_count": 7, @@ -206,7 +206,7 @@ { "data": { "text/plain": [ - "[400, 3]" + "['300', 3]" ] }, "execution_count": 8, @@ -226,7 +226,7 @@ { "data": { "text/plain": [ - "[400, 3]" + "['400', 4]" ] }, "execution_count": 9, @@ -238,6 +238,424 @@ "jmk.conductor_size(1000, temp = 75, material = 'al', code = 'CEC', raceway = True, ambient = 30, max = 500)\n" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Sometimes its going to be easier to use a cable list and build a cable schedule from that. Here is an example of how to do that." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "First, create a cable list with these fields.\n", + "The first line is the columns for the list\n", + "The second line initializes the list with the first cable, and the following lines add to that list.\n", + "\n", + "Finally we can convert this to a dataframe so that it's easier to look at in the notebook." + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
Cable TagToFromDistance [m]WirewayVoltagePhasesAmpsNeutralLoad TypeNotes
0P100CBMUtility10conduit2401100TrueNoneNone
1P101MeterCBM2conduit2401100TrueNoneNone
2P102CB1Meter2conduit2401100TrueNoneNone
3P103CB2CB1350conduit2401100FalseNoneCUSTOM
4P104TX1CB23conduit2401100TruexfmrpNone
5P105CB3TX13conduit2401100TruexfmrsNone
6P106ShedCB320conduit2401100TrueNoneNone
\n", + "
" + ], + "text/plain": [ + " Cable Tag To From Distance [m] Wireway Voltage Phases Amps Neutral \\\n", + "0 P100 CBM Utility 10 conduit 240 1 100 True \n", + "1 P101 Meter CBM 2 conduit 240 1 100 True \n", + "2 P102 CB1 Meter 2 conduit 240 1 100 True \n", + "3 P103 CB2 CB1 350 conduit 240 1 100 False \n", + "4 P104 TX1 CB2 3 conduit 240 1 100 True \n", + "5 P105 CB3 TX1 3 conduit 240 1 100 True \n", + "6 P106 Shed CB3 20 conduit 240 1 100 True \n", + "\n", + " Load Type Notes \n", + "0 None None \n", + "1 None None \n", + "2 None None \n", + "3 None CUSTOM \n", + "4 xfmrp None \n", + "5 xfmrs None \n", + "6 None None " + ] + }, + "execution_count": 10, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "cable_list_columns = [['Cable Tag', 'To', 'From', 'Distance [m]', 'Wireway', 'Voltage', 'Phases', 'Amps','Neutral','Load Type','Notes']]\n", + "cable_list = [['P100','CBM','Utility',10,'conduit',240,1,100,True,None,None]]\n", + "cable_list.append(['P101','Meter','CBM',2,'conduit',240,1,100,True])\n", + "cable_list.append(['P102','CB1','Meter',2,'conduit',240,1,100,True])\n", + "cable_list.append(['P103','CB2','CB1',350,'conduit',240,1,100,False,None,'CUSTOM'])\n", + "cable_list.append(['P104','TX1','CB2',3,'conduit',240,1,100,True,'xfmrp'])\n", + "cable_list.append(['P105','CB3','TX1',3,'conduit',240,1,100,True,'xfmrs'])\n", + "cable_list.append(['P106','Shed','CB3',20,'conduit',240,1,100,True])\n", + "\n", + "cable_list_df = pd.DataFrame(cable_list, columns=cable_list_columns)\n", + "cable_list = cable_list_df.values.tolist() # Creates a 2D list that has the None values. Makes it easier to create the append list by hand\n", + "cable_list_df" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Using that list we can create a cable schedule that will have all the necessary information to add to a drawing. This cell creates a 2D list with all the information including for both copper and aluminum conductors. " + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "add parallel runs\n", + "add parallel runs\n" + ] + } + ], + "source": [ + "cable_schedule_columns = ['CABLE TAG', 'COPPER CONDUCTOR', 'ALUMINUM CONDUCTOR', 'CONDUIT', 'DETAIL', 'NOTE']\n", + "cable_list_schedule = None\n", + "\n", + "for i in range(len(cable_list)):\n", + " \n", + "\n", + " tag = cable_list[i][0]\n", + " distance = cable_list[i][3]\n", + " wireway = cable_list[i][4]\n", + " voltage = cable_list[i][5]\n", + " load = cable_list[i][7]\n", + " neutral = cable_list[i][8]\n", + " load_type = cable_list[i][9]\n", + " \n", + " \n", + " if wireway == 'conduit':\n", + " raceway = True\n", + " else:\n", + " raceway = False\n", + "\n", + " if neutral == False:\n", + " num_conductors = 2\n", + " else:\n", + " num_conductors = 3\n", + "\n", + " cu = 'cu'\n", + " min_conductor_cu = jmk.conductor_size(load, temp = 75, material = cu, raceway = raceway, max = 750, load_type = load_type)\n", + " voltage_drop = jmk.voltage_drop(voltage, load, min_conductor_cu[0], distance,material =cu, num_runs = min_conductor_cu[1])[1]\n", + "\n", + " if voltage_drop < 3:\n", + " conductor_cu = min_conductor_cu[0]\n", + " runs_cu = min_conductor_cu[1]\n", + " else:\n", + " runs_cu = min_conductor_cu[1]\n", + " conductor_cu = jmk.voltage_drop_conductors(voltage,load,distance,v_drop_percent = 0.03,runs = runs_cu,material=cu)\n", + " while True:\n", + " if conductor_cu != 'add parallel runs':\n", + " break\n", + "\n", + " runs_cu = runs_cu + 1\n", + " conductor_cu = jmk.voltage_drop_conductors(voltage,load,distance,v_drop_percent = 0.03,runs = runs_cu,material=cu)\n", + "\n", + " al = 'al'\n", + " min_conductor_al = jmk.conductor_size(load, temp = 75, material = al, raceway = raceway, max = 750, load_type = load_type)\n", + " voltage_drop = jmk.voltage_drop(voltage, load, min_conductor_al[0], distance,material =al, num_runs = min_conductor_al[1])[1]\n", + "\n", + " if voltage_drop < 3:\n", + " conductor_al = min_conductor_al[0]\n", + " runs_al = min_conductor_al[1]\n", + " else:\n", + " runs_al = min_conductor_al[1]\n", + " conductor_al = jmk.voltage_drop_conductors(voltage,load,distance,v_drop_percent = 0.03,runs = runs_al,material=al)\n", + " while True:\n", + " if conductor_al != 'add parallel runs':\n", + " break\n", + "\n", + " runs_al = runs_al + 1\n", + " conductor_al = jmk.voltage_drop_conductors(voltage,load,distance,v_drop_percent = 0.03,runs = runs_al,material=al)\n", + "\n", + "\n", + " if cable_list_schedule == None:\n", + " cable_list_schedule = [[tag,jmk.cable_schedule_naming(conductor_cu,num_conductors,runs = runs_cu,bond='BOND'),jmk.cable_schedule_naming(conductor_al,num_conductors,runs = runs_al,bond='BOND'),wireway,'','']]\n", + " else: \n", + " cable_list_schedule.append([tag,jmk.cable_schedule_naming(conductor_cu,num_conductors,runs = runs_cu,bond='BOND'),jmk.cable_schedule_naming(conductor_al,num_conductors,runs = runs_al,bond='BOND'),wireway,'',''])\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "And this is what the list looks like in a dataframe. You can then export this dataframe to a CSV or excel format to datalink to a table in your drawings." + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
CABLE TAGCOPPER CONDUCTORALUMINUM CONDUCTORCONDUITDETAILNOTE
0P1003C #2AWG + BOND3C #1/0AWG + BONDconduit
1P1013C #2AWG + BOND3C #1/0AWG + BONDconduit
2P1023C #2AWG + BOND3C #1/0AWG + BONDconduit
3P1032x 2C #4/0AWG + BOND2x 2C #350kcmil + BONDconduit
4P1043C #1AWG + BOND3C #2/0AWG + BONDconduit
5P1053C #1AWG + BOND3C #2/0AWG + BONDconduit
6P1063C #2AWG + BOND3C #1/0AWG + BONDconduit
\n", + "
" + ], + "text/plain": [ + " CABLE TAG COPPER CONDUCTOR ALUMINUM CONDUCTOR CONDUIT DETAIL NOTE\n", + "0 P100 3C #2AWG + BOND 3C #1/0AWG + BOND conduit \n", + "1 P101 3C #2AWG + BOND 3C #1/0AWG + BOND conduit \n", + "2 P102 3C #2AWG + BOND 3C #1/0AWG + BOND conduit \n", + "3 P103 2x 2C #4/0AWG + BOND 2x 2C #350kcmil + BOND conduit \n", + "4 P104 3C #1AWG + BOND 3C #2/0AWG + BOND conduit \n", + "5 P105 3C #1AWG + BOND 3C #2/0AWG + BOND conduit \n", + "6 P106 3C #2AWG + BOND 3C #1/0AWG + BOND conduit " + ] + }, + "execution_count": 12, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df = pd.DataFrame(cable_list_schedule, columns=cable_schedule_columns)\n", + "df" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -256,7 +674,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 13, "metadata": {}, "outputs": [ { @@ -265,7 +683,7 @@ "37" ] }, - "execution_count": 10, + "execution_count": 13, "metadata": {}, "output_type": "execute_result" } @@ -283,7 +701,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 14, "metadata": {}, "outputs": [ { @@ -292,7 +710,7 @@ "33" ] }, - "execution_count": 11, + "execution_count": 14, "metadata": {}, "output_type": "execute_result" } @@ -300,6 +718,11 @@ "source": [ "jmk.panels_per_string(1500,40,beta=-0.5,temp = 2)" ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [] } ], "metadata": { @@ -318,7 +741,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.2" + "version": "3.10.1" } }, "nbformat": 4,