Finding the diameter of a wire

In summary, The mentor node added code tags and the From=menu('select:','c', 'g', 'a', 's:'); line. The current copper, gold, silver, and resistivity for aluminum, copper, gold, and silver were calculated.
  • #1
Leanne
14
4
Homework Statement
I'm trying to find the diameter of a wire knowing the length, volts, current, and resistivity, and then code it in Matlab. I've been working on it for hours and I can't seem to get it right. Can anyone help?
Relevant Equations
V=IR, R=(pl)/A, A=pi(0.5d)^2 and resistivity for aluminum, copper, gold, and silver.
Mentor node: Added code tags
From=menu('select:','c', 'g', 'a', 's:'); This is part of my code and I'm not coming up with anything close
Matlab:
l=input('input wire length')    %current copper=12.5572                                               to the right answer.  :/
V=input('input Voltage')        %current gold=8.8518e-08
        switch From             %current aluminum= 7.8540
    case 1                      %current silver=   13.5839
        cp='1.72*10^-8 ohm/m';
        b=l*cp;
        v=110;
        r=v/12.5572;
        A=b/r;
        x=A/pi;
        rad=sqrt(x);
        dia=rad*2
 
Last edited by a moderator:
Physics news on Phys.org
  • #2
Leanne said:
Homework Equations: V=IR, R=(pl)/A, A=pi(0.5d)^2 and resistivity for aluminum, copper, gold, and silver.

cp='1.72*10^-8 ohm/m';
Is this express ##\rho##, electrical resistivity, whose unit is ohm m, not ohm/m ?
 
  • #3
Shouldn't you have an input for the current too, I see you divide voltage by 12.5572 to find r which I suppose is the resistance, is the current fixed to 12.5572 for some reason?
 
  • #4
Can you provide a list of all the variables that go into the calculation for, say, copper including the length of the wire? Also, please provide the answer that you got and what you think is the correct answer. This information will help us help you better.
 
  • #5
mitochan said:
Is this express ##\rho##, electrical resistivity, whose unit is ohm m, not ohm/m ?
mitochan said:
Is this express ##\rho##, electrical resistivity, whose unit is ohm m, not ohm/m ?
 
  • #6
Yes, p is resistivity in ohm/m. For copper it is 1.72*10^-8.
 
  • #7
kuruman said:
Can you provide a list of all the variables that go into the calculation for, say, copper including the length of the wire? Also, please provide the answer that you got and what you think is the correct answer. This information will help us help you better.
I'm trying to write a program where the user can input any length, voltage, or wire current. I know that V=IR, R=(ρL)/A, and that A=π(0.5d)^2. In a previous program that I wrote, I found the current (I) and that is where I got 12.5575 (for copper). The length was 10000m and the voltage was 110. The resistivity (ρ) for copper is 1.72*10^-8 ohm/m. I also have the other resistivitys for the other types of metal I'll be incorporating, but I'm just trying to first get the copper to come out with the correct answer which is going to be .005 (I'm 99% sure). When figuring the copper, I'm using the same measurements from the previous code which is L=10000 and V=110. I just can't seem to get it into code. Thanks for your help!
 
  • #8
I'm sorry the .005 answer is wrong. That number was from the code I used to find current.
 
  • #9
Last edited:
  • #10
Leanne said:
I'm trying to write a program where the user can input any length, voltage, or wire current. I know that V=IR, R=(ρL)/A, and that A=π(0.5d)^2. In a previous program that I wrote, I found the current (I) and that is where I got 12.5575 (for copper). The length was 10000m and the voltage was 110. The resistivity (ρ) for copper is 1.72*10^-8 ohm/m. I also have the other resistivitys for the other types of metal I'll be incorporating, but I'm just trying to first get the copper to come out with the correct answer which is going to be .005 (I'm 99% sure). When figuring the copper, I'm using the same measurements from the previous code which is L=10000 and V=110. I just can't seem to get it into code. Thanks for your help!
Sure. What if you streamlined your code by doing some algebra to obtain a single algebraic expression for the diameter in terms of the input parameters, namely ##d=f(L,V,I,\rho)##? Then the code will be easier to execute and troubleshoot. I did just that and for ##L=1000~\mathrm{m},~V=110~\mathrm{V},~I=12.55~ \mathrm{A},~\rho_{Cu}=1.72 \times 10^{-8}~\mathrm{\Omega\cdot m}##,
I get the diameter to be ##d=1.6\times 10^{-3}~\mathrm{m}##.
 
  • #11
Thanks so much for this! I'm not at home right now, but when I get there I'll use your equation on all of my wires and let you know. I appreciate it so much! :)
 
  • #12
OK. Just to be sure, please post the equation you derive so that we can compare notes.
 
  • #13
Hey. I'm so frustrated with this and I've been working on it for days and my brain is completely boggled and I can't even think straight about it anymore. I used your equation and I'm getting a different answer than you. It's probably somewhere in my code, and then I don't understand physics at all. I'm brand new at all of this. So, I'm going to go back to school on Friday and I will get help from my instructor with this and I will get back to you and show you the solution. Thank you for your efforts!
 
  • Like
Likes neilparker62 and Delta2
  • #14
Leanne said:
Hey. I'm so frustrated with this and I've been working on it for days and my brain is completely boggled and I can't even think straight about it anymore. I used your equation and I'm getting a different answer than you. It's probably somewhere in my code, and then I don't understand physics at all. I'm brand new at all of this. So, I'm going to go back to school on Friday and I will get help from my instructor with this and I will get back to you and show you the solution. Thank you for your efforts!
Thanks for your honesty. Along the lines of what Kuruman suggests above, I would try and find a single expression for variable A (area) based on your equations for Ohm's law (V=IR) and resistance (R=ρL/A). From there to radius/diameter it is just a question of re-arranging the standard formula for area of a circle (A=πr^2 or A=πd^2/4).
 
  • #15
Leanne said:
Hey. I'm so frustrated with this and I've been working on it for days and my brain is completely boggled and I can't even think straight about it anymore. I used your equation and I'm getting a different answer than you. It's probably somewhere in my code, and then I don't understand physics at all. I'm brand new at all of this. So, I'm going to go back to school on Friday and I will get help from my instructor with this and I will get back to you and show you the solution. Thank you for your efforts!
You have not explained why you think your code is wrong. In post #7 you wrote that the output should be 5mm, and the site I used in post #9 confirmed that, but in post #8 you said that was wrong.
Please supply an example output from your program and what you think the output should be.
 
  • #16
Hello again,
I haven't been to class yet, but I have worked on this a lot. I know this code looks like a lot, but I do think the answer was .005 for the copper. I just got confused when I withdrew that statement before. Now though, ALL of my answers are rounding to .005. Can this be true? I used a length of 10000m and volts of 110. The current for each wire at this length & volts is in the code as well as you will see. So is it that every kind of wire requires a 5cm diameter? I did this on paper as well because it just didn't seem like I should be getting the same answer, and that's what I got there too. Can you just peek at it? Thanks much!
From=menu('select:','c', 'a', 'g', 's');
copper='1.72-10^-8 ohm/m';
aluminum='2.75*10^-8 ohm/m';
gold='2.44*10^-8 ohm/m';
silver='1.59*10^-8 ohm/m';
switch From
case 1
cc=.0000000172;
l=10000;
v=110;
ci=12.5572;
a=.25;
nu=cc*l*ci;
de=a*pi*v;
dd=nu/de;
diameter=sqrt(dd)
case 2
ac=.0000000275;
l=10000;
v=110;
ai=7.8540;
a=.25;
anu=ac*l*ai;
ade=a*pi*v;
add=anu/ade;
adiameter=sqrt(add)
case 3
g=.0000000244;
l=10000;
v=110;
gi=8.8518;
a=.25;
gnu=g*l*gi;
gde=a*pi*v;
gd=gnu/gde;
gdiameter=sqrt(gd)
case 4
s=.0000000159;
l=10000;
v=110;
si=13.5839;
a=.25;
sn=s*l*si;
sd=a*pi*v;
ss=sn/sd;
sdiameter=sqrt(ss)

end
 
  • #17
With due respect, it's no use coding until you have clarified for yourself the formula you want to code. If you were to do this exercise using a calculator, what formula(s) would you use ? I recommend you study post #10 carefully.
 
  • Like
Likes BvU
  • #18
Here's a spreadsheet version of what your program should be doing. I'm using l = 1000m (as in Post 10) so as not to do your exact problem. But it does look as though the answers for all the metals are the same.

GivenGivenCalculateGivenGivenCalculateCalculate
VoltsCurrentResistanceResisitivityLengthAreaDiameter
Copper
110​
12.5572​
8.760​
1.72E-08​
1000​
1.96E-06​
0.001581136​
Aluminium
110​
7.854​
14.006​
2.75E-08​
1000​
1.96E-06​
0.001581141​
Gold
110​
8.8518​
12.427​
2.44E-08​
1000​
1.96E-06​
0.001581137​
Silver
110​
13.5839​
8.098​
1.59E-08​
1000​
1.96E-06​
0.001581137​
 
  • Like
Likes Delta2
  • #19
Leanne said:
Hello again,
I haven't been to class yet, but I have worked on this a lot. I know this code looks like a lot, but I do think the answer was .005 for the copper. I just got confused when I withdrew that statement before. Now though, ALL of my answers are rounding to .005. Can this be true? I used a length of 10000m and volts of 110. The current for each wire at this length & volts is in the code as well as you will see. So is it that every kind of wire requires a 5cm diameter? I did this on paper as well because it just didn't seem like I should be getting the same answer, and that's what I got there too. Can you just peek at it? Thanks much!
From=menu('select:','c', 'a', 'g', 's');
copper='1.72-10^-8 ohm/m';
aluminum='2.75*10^-8 ohm/m';
gold='2.44*10^-8 ohm/m';
silver='1.59*10^-8 ohm/m';
switch From
case 1
cc=.0000000172;
l=10000;
v=110;
ci=12.5572;
a=.25;
nu=cc*l*ci;
de=a*pi*v;
dd=nu/de;
diameter=sqrt(dd)
case 2
ac=.0000000275;
l=10000;
v=110;
ai=7.8540;
a=.25;
anu=ac*l*ai;
ade=a*pi*v;
add=anu/ade;
adiameter=sqrt(add)
case 3
g=.0000000244;
l=10000;
v=110;
gi=8.8518;
a=.25;
gnu=g*l*gi;
gde=a*pi*v;
gd=gnu/gde;
gdiameter=sqrt(gd)
case 4
s=.0000000159;
l=10000;
v=110;
si=13.5839;
a=.25;
sn=s*l*si;
sd=a*pi*v;
ss=sn/sd;
sdiameter=sqrt(ss)

end
Your program is plugging in values for currents, and these depend on the metal.
Where are you getting those currents from? If your program is supposed to be calculating the wire thickness then the user should be making three inputs: metal species, voltage and current.
The values of current you are plugging in seem all to be based on a diameter of 5mm, so of course that's the diameter your program calculates.
 
  • #20
Hello. The resistivity was given. In my code, rather than writing 1.72×10^-8 ohm/m, I wrote .0000000172. Also, the current (i) was calculated for these inputs in a previous code we did in class. I know in my first post I said that the user would input the length, volts, and type of metal. I misunderstood and the only thing they will input is the kind of metal. The volts will be 110 and the length will be 10000m. The formula I used is: resistivity×lengthxcurrent / area*pi*volts then sqrt the answer. Every answer isn't the exact same, but every answer rounds to .005 or 5cm, so I was thinking I had to have calculated something wrong, but maybe not. Thank you for sharing the chart.
 
  • #21
I still don't understand though how the required diameters all are the same size. I was expecting for each to be different since there are different variables& I'm using the same equation for every wire type. How is this?
 
  • #22
Leanne said:
I still don't understand though how the required diameters all are the same size. I was expecting for each to be different since there are different variables& I'm using the same equation for every wire type. How is this?
It is because you have encoded in the program the current you will get for the given metal and voltage and a diameter of 5mm. Therefore the program will always calculate the diameter as 5mm. To get any other result you must let the user supply the current.
 
  • #23
Hmmm. Okay. Thanks for answering these questions. As you can tell, I am brand new at this, and not good at physics or math all. ;) So maybe tonight I will plug in the equation for the current to be calculated without me coding it in. That wasn't my assignment, but it's good to learn this stuff. :)
 
  • #24
Leanne said:
Hmmm. Okay. Thanks for answering these questions. As you can tell, I am brand new at this, and not good at physics or math all. ;) So maybe tonight I will plug in the equation for the current to be calculated without me coding it in. That wasn't my assignment, but it's good to learn this stuff. :)
Your difficulty in your original code is not to do with physics or math; it is the simple logic that if you plug in values for the currents that were obtained using a diameter of 5mm then of course it will calculate 5mm as the answer!
Take those current values out of you code and get the user to specify the current and your problem is solved.

In your later code you have introduced this symbol a (do you really mean this to be area?) and set it to 0.25. What is this doing?
I spent my working life writing software. You must develop the habit of writing comments to explain what your variables represent and the reasoning behind the steps in your code.
 
Last edited:
  • Like
Likes jbriggs444 and Delta2
  • #25
Leanne said:
Hello. The resistivity was given. In my code, rather than writing 1.72×10^-8 ohm/m, I wrote .0000000172. Also, the current (i) was calculated for these inputs in a previous code we did in class. I know in my first post I said that the user would input the length, volts, and type of metal. I misunderstood and the only thing they will input is the kind of metal. The volts will be 110 and the length will be 10000m. The formula I used is: resistivity×lengthxcurrent / area*pi*volts then sqrt the answer. Every answer isn't the exact same, but every answer rounds to .005 or 5cm, so I was thinking I had to have calculated something wrong, but maybe not. Thank you for sharing the chart.
In order to calculate diameter, you first need to determine the cross-sectional area of the wire as indicated in my chart. Thus area cannot appear as a variable in your formula. In your code you refer to a variable a which has a value of 0.25. I think this value relates to the formula A= π d^2 / 4 since 1/4 = 0.25. Your formula should therefore read: (resistivity×lengthxcurrentx4) / (pi*volts). The factor 4/pi 'converts' area to d^2.
 
Last edited:
  • #26
haruspex said:
It is because you have encoded in the program the current you will get for the given metal and voltage and a diameter of 5mm. Therefore the program will always calculate the diameter as 5mm. To get any other result you must let the user supply the current.
But actually I didn't code the program to be set at 5cm. That is the result I am getting from every type of wire. The coding the length, volts, resist, and current, and the output is .005 every time. I never set the
haruspex said:
Your difficulty in your original code is not to do with physics or math; it is the simple logic that if you plug in values for the currents that were obtained using a diameter of 5mm then of course it will calculate 5mm as the answer!
Take those current values out of you code and get the user to specify the current and your problem is solved.

In your later code you have introduced this symbol a (do you really mean this to be area?) and set it to 0.25. What is this doing?
I spent my working life writing software. You must develop the habit of writing comments to explain what your variables represent and the reasoning behind the steps in your code.
The reason I set a (area) to .25 is because the equation I got from school said a=pi(d)^2. So I changed it to .25 for convenience. And yes I understand what you're saying about the logic. :)
 
  • #27
Leanne said:
the equation I got from school said a=pi(d)^2
I think you mean a=pi(d)^2/4. So your a is not "area", it is simply the constant 1/4.
Leanne said:
But actually I didn't code the program to be set at 5cm.
I asked in post #19 where you got the current values to plug into your code. You have not answered this. My belief is that you got these from either an experiment or sample set of data in which the actual diameter was 5mm for all metals. By plugging these numbers in you have effectively set the answer for the diameter to be 5mm.

Take out those constants for current and get it as an input from the user. It simply makes no sense to have them fixed the code.

Edit: another tip regarding coding style. Unlike school algebra, software is far more readable if you use meaningful names instead of single letters for variables.
 

What is the purpose of finding the diameter of a wire?

The diameter of a wire is an important measurement in determining its conductivity, strength, and overall performance. It can also help in selecting the appropriate wire for a specific application.

How do I measure the diameter of a wire?

The most accurate way to measure the diameter of a wire is to use a micrometer or a caliper. These tools provide precise measurements in millimeters or inches. Alternatively, you can also use a wire gauge tool, which measures the diameter of a wire in terms of gauge size.

What factors can affect the diameter of a wire?

The diameter of a wire can be affected by the type of material it is made of, the manufacturing process, and the amount of tension applied during production. Other factors include temperature, stretching, and corrosion.

Why is it important to measure the diameter of a wire accurately?

Accurately measuring the diameter of a wire is crucial in ensuring its proper performance and safety. A wire with a larger diameter can handle more current without overheating, while a smaller diameter wire may overheat and cause a fire hazard.

Can the diameter of a wire change over time?

Yes, the diameter of a wire can change over time due to factors such as stretching, corrosion, or wear and tear. It is important to regularly check the diameter of wires in high-stress applications to ensure they are still within the appropriate range for safety and performance.

Similar threads

Replies
2
Views
22K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
955
  • Introductory Physics Homework Help
Replies
4
Views
4K
  • Introductory Physics Homework Help
Replies
8
Views
3K
Replies
6
Views
2K
  • Introductory Physics Homework Help
Replies
6
Views
3K
  • Introductory Physics Homework Help
Replies
2
Views
969
  • Introductory Physics Homework Help
Replies
2
Views
6K
  • Introductory Physics Homework Help
Replies
2
Views
5K
  • Introductory Physics Homework Help
Replies
4
Views
9K
Back
Top