Class: Eletro::Wire

Inherits:
Part
  • Object
show all
Defined in:
lib/eletro/wire.rb

Constant Summary collapse

MULT =
{ :mil => 2.54e-3, :mm => 0.1, :um => 1e-4 }
TEMP =
25
RHO =
1.7e-6
ALPHA =

//ohm/ohm/C

3.9e-3
LEN =
1
TEMP_RISE =
10
THICKNESS =
0.1
IRISE =
{
  :internal => { :k => 0.048, :b => 0.44, :c => 0.725 },
  :external => { :k => 0.024, :b => 0.44, :c => 0.725 }
  # return Math.pow((current/(k*Math.pow(rise,b))),1/c)

}

Instance Attribute Summary collapse

Attributes inherited from Part

#i, #p0, #p1, #unit, #v, #value

Instance Method Summary collapse

Methods inherited from Part

#*, #+, #-, #/, #abs, #coerce, #method_missing, #round, #to_f, #to_i, #to_s

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Eletro::Part

Instance Attribute Details

#lengthObject

Returns the value of attribute length.



22
23
24
# File 'lib/eletro/wire.rb', line 22

def length
  @length
end

#thicknessObject

Returns the value of attribute thickness.



22
23
24
# File 'lib/eletro/wire.rb', line 22

def thickness
  @thickness
end

#widthObject

Returns the value of attribute width.



22
23
24
# File 'lib/eletro/wire.rb', line 22

def width
  @width
end

Instance Method Details

#area(place) ⇒ Object



34
35
36
# File 'lib/eletro/wire.rb', line 34

def area(place)
  @area = (i / IRISE[place][:k] * (TEMP_RISE ** IRISE[place][:b])) ** (1/IRISE[place][:c])
end

#calc(pos = :external) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/eletro/wire.rb', line 42

def calc(pos = :external)
  area = area(pos) #, @temp_rise || TEMP_RISE) #  //mils^2
  area = area * 2.54 * 2.54 / 1e6 # //mil^2 to cm^2
  wi = area / tk
  wi = wi / MULT[@mult || :mm]
  tval = 1 * (@temp || TEMP) + 1 * TEMP_RISE
  ri = (RHO * LEN / area) * (1 + ALPHA * (tval-25))
  vi = ri * i
  pi = i * i * ri

  # ae = area
  # ae = ae * 2.54 * 2.54 / 1e6 #  //mil^2 to cm^2
  # we = ae/tk # //cm
  # we = we/document.getElementById("twSelect3").value # //user units
  # re = (rho*len/ae)*(1+alpha*(tval-25))
  # ve = re*i
  # pe = i*i*re

end

#sizeObject



62
63
64
# File 'lib/eletro/wire.rb', line 62

def size
  calc
end

#spacingObject



24
25
26
27
28
29
30
31
32
# File 'lib/eletro/wire.rb', line 24

def spacing
  case v
  when 0..100 then [0.005, 0.004]
  when 101..300 then [0.015, 0.008]
  when 301..500 then [0.030, 0.010]
  else
    0.030 * ( v / 500)
  end
end

#tkObject



38
39
40
# File 'lib/eletro/wire.rb', line 38

def tk
  @tk || THICKNESS
end