PyGamLab 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- PyGamLab/Constants.py +500 -0
- PyGamLab/Convertos.py +1728 -0
- PyGamLab/Data_Analysis.py +3623 -0
- PyGamLab/Functions.py +4507 -0
- PyGamLab/__init__.py +45 -0
- pygamlab-0.1.0.dist-info/METADATA +122 -0
- pygamlab-0.1.0.dist-info/RECORD +9 -0
- pygamlab-0.1.0.dist-info/WHEEL +5 -0
- pygamlab-0.1.0.dist-info/top_level.txt +1 -0
PyGamLab/Functions.py
ADDED
|
@@ -0,0 +1,4507 @@
|
|
|
1
|
+
'''
|
|
2
|
+
Functions.py ==>
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
'''
|
|
6
|
+
|
|
7
|
+
#" IN GOD WE TRUST, ALL OTHERS MUST BRING DATA"
|
|
8
|
+
# -W. Edwards Deming
|
|
9
|
+
#------------------------------------------------------------------------------
|
|
10
|
+
# Copyright 2023 The Gamlab Authors. All Rights Reserved.
|
|
11
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
12
|
+
# you may not use this file except in compliance with the License.
|
|
13
|
+
# You may obtain a copy of the License at
|
|
14
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
15
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
16
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
17
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
18
|
+
# See the License for the specific language governing permissions and
|
|
19
|
+
# limitations under the License.
|
|
20
|
+
#------------------------------------------------------------------------------
|
|
21
|
+
'''
|
|
22
|
+
The Scientific experimental simulation library
|
|
23
|
+
-------------------------------------------------------------------------------
|
|
24
|
+
Graphen & Advanced Material Laboratory
|
|
25
|
+
|
|
26
|
+
it aimes to provide new scientist to use data,simlation, prepared data
|
|
27
|
+
and Artificial intelligence models.
|
|
28
|
+
|
|
29
|
+
See http://gamlab.aut.ac.ir for complete documentation.
|
|
30
|
+
'''
|
|
31
|
+
__doc__='''
|
|
32
|
+
|
|
33
|
+
@author: Ali Pilehvar Meibody (Alipilehvar1999@gmail.com)
|
|
34
|
+
|
|
35
|
+
888 888
|
|
36
|
+
.d8888b .d88b. 88888b.d88b. 888 .d88b. 888
|
|
37
|
+
d88P" d88""88b 888 "888 "88b 888 d88""88b 88888PP
|
|
38
|
+
888 8888 888 888 888 888 888 888 888 888 888 888
|
|
39
|
+
Y88b. 88 Y88..88PP. 888 888 888 888...... Y88..88PP. 888 888
|
|
40
|
+
"Y8888P8 "Y88P8888 888 888 888 888888888 "Y88P8888 88888888
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
@Director of Gamlab: Professor M. Naderi (Mnaderi@aut.ac.ir)
|
|
44
|
+
|
|
45
|
+
@Graphene Advanced Material Laboratory: https://www.GamLab.Aut.ac.ir
|
|
46
|
+
|
|
47
|
+
'''
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
#import-----------------------------------------
|
|
51
|
+
import math
|
|
52
|
+
import statistics
|
|
53
|
+
import random
|
|
54
|
+
import numpy as np
|
|
55
|
+
import pandas as pd
|
|
56
|
+
import matplotlib as plt
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def Activation_Energy(k,k0,T):
|
|
63
|
+
K=math.log(k)
|
|
64
|
+
R=8.3144598
|
|
65
|
+
|
|
66
|
+
K0=math.log(k0)
|
|
67
|
+
Ea=(K0-K)*R*T
|
|
68
|
+
return Ea
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def Atomic_Packing_Factor(radius , crystal_structure):
|
|
75
|
+
|
|
76
|
+
'''
|
|
77
|
+
Parameters
|
|
78
|
+
----------
|
|
79
|
+
|
|
80
|
+
crystal_structure: Type of the crystal (Fccc , Bcc or ...)
|
|
81
|
+
radiuse (float): Atomic Atomic radius in crystal structure (nm)
|
|
82
|
+
|
|
83
|
+
Returns:
|
|
84
|
+
Atomic packing factor for SC , BCC , FCC
|
|
85
|
+
|
|
86
|
+
'''
|
|
87
|
+
|
|
88
|
+
if crystal_structure.upper() == "SC":
|
|
89
|
+
volume = (4/3) * math.pi * radius ** 3
|
|
90
|
+
cell_volume = radius * 2
|
|
91
|
+
APF = volume / cell_volume ** 3
|
|
92
|
+
|
|
93
|
+
elif crystal_structure.upper() == "BCC":
|
|
94
|
+
volume = (4/3) * math.pi * radius ** 3
|
|
95
|
+
cell_volume = 4 * radius * math.sqrt(3) / 2
|
|
96
|
+
APF = volume / cell_volume ** 3
|
|
97
|
+
|
|
98
|
+
elif crystal_structure.upper() == "FCC":
|
|
99
|
+
volume = (4/3) * math.pi * radius ** 3
|
|
100
|
+
cell_volume = 16 * radius / math.sqrt(2)
|
|
101
|
+
APF = volume / cell_volume ** 3
|
|
102
|
+
|
|
103
|
+
else:
|
|
104
|
+
print("Invalid crystal structure. Please enter SC , BCC or FCC")
|
|
105
|
+
return None
|
|
106
|
+
|
|
107
|
+
return APF
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
def Activity_Coef(wB,wC,wD,eBB,eCB,eDB):
|
|
117
|
+
'''
|
|
118
|
+
|
|
119
|
+
Parameters
|
|
120
|
+
----------
|
|
121
|
+
wB : float
|
|
122
|
+
Weight percent of B
|
|
123
|
+
wC : float
|
|
124
|
+
Weight percent of C
|
|
125
|
+
wD : float
|
|
126
|
+
Weight percent of D
|
|
127
|
+
eBB : float
|
|
128
|
+
Interaction coefficient of B and B
|
|
129
|
+
eCB : float
|
|
130
|
+
Interaction coefficient of C and B
|
|
131
|
+
eDB : float
|
|
132
|
+
Interaction coefficient of D and B
|
|
133
|
+
|
|
134
|
+
Returns
|
|
135
|
+
-------
|
|
136
|
+
fB : float
|
|
137
|
+
Activity coefficient of B
|
|
138
|
+
|
|
139
|
+
'''
|
|
140
|
+
|
|
141
|
+
fB=math.e**(eBB*wB+eCB*wC+eDB*wD)
|
|
142
|
+
|
|
143
|
+
return fB
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
def Arithmetic_Sequence(start_num,common_difference,n):
|
|
149
|
+
'''
|
|
150
|
+
An arithmetic sequence is an ordered set of numbers that have a common difference between each consecutive term.
|
|
151
|
+
Parameters
|
|
152
|
+
----------
|
|
153
|
+
start_num : int
|
|
154
|
+
the first term in the sequence.
|
|
155
|
+
common_difference : int
|
|
156
|
+
the common difference between terms.
|
|
157
|
+
n : int
|
|
158
|
+
number of terms.
|
|
159
|
+
|
|
160
|
+
Returns
|
|
161
|
+
-------
|
|
162
|
+
a_n :int
|
|
163
|
+
the nᵗʰ term in the sequence
|
|
164
|
+
|
|
165
|
+
'''
|
|
166
|
+
a_n = start_num + ((n - 1)*common_difference)
|
|
167
|
+
return a_n
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
def Aeroscope_Stress_Concentration(max_stress,nominal_stresss):
|
|
173
|
+
K=max_stress/nominal_stresss
|
|
174
|
+
return K
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
def archimedes_principle(density_fluid, volume_displaced, gravitational_acceleration):
|
|
180
|
+
return density_fluid * volume_displaced * gravitational_acceleration
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
def Atomic_Percentage(n_1,n_2,n_3,n_4,Entry,output,m_1,m_2,m_3,m_4,M_1,M_2,M_3,M_4,w_1,w_2,w_3,w_4):
|
|
186
|
+
'''
|
|
187
|
+
Parameters
|
|
188
|
+
----------
|
|
189
|
+
n_1 : float
|
|
190
|
+
The number of moles of the first atom.
|
|
191
|
+
n_2 : float
|
|
192
|
+
The number of moles of the second atom.
|
|
193
|
+
n_3 : float
|
|
194
|
+
The number of moles of the third atom.
|
|
195
|
+
n_4 : float
|
|
196
|
+
The number of moles of the fourth atom.
|
|
197
|
+
Entry : str
|
|
198
|
+
what type of entery you have?
|
|
199
|
+
output : str
|
|
200
|
+
The atomic percentage is based on which atom?
|
|
201
|
+
m_1 : float
|
|
202
|
+
The mass of the first atom.
|
|
203
|
+
m_2 : float
|
|
204
|
+
The mass of the second atom.
|
|
205
|
+
m_3 : float
|
|
206
|
+
The mass of the third atom.
|
|
207
|
+
m_4 : float
|
|
208
|
+
The mass of the fourth atom.
|
|
209
|
+
M_1 : float
|
|
210
|
+
The atomic mass of the first atom.
|
|
211
|
+
M_2 : float
|
|
212
|
+
The atomic mass of the second atom.
|
|
213
|
+
M_3 : float
|
|
214
|
+
The atomic mass of the third atom.
|
|
215
|
+
M_4 : float
|
|
216
|
+
The atomic mass of the fourth atom.
|
|
217
|
+
w_1 : float
|
|
218
|
+
The weight percentage of the first atom.
|
|
219
|
+
w_2 : float
|
|
220
|
+
The weight percentage of the second atom.
|
|
221
|
+
w_3 : float
|
|
222
|
+
The weight percentage of the third atom.
|
|
223
|
+
w_4 : float
|
|
224
|
+
The weight percentage of the fourth atom.
|
|
225
|
+
|
|
226
|
+
Returns
|
|
227
|
+
-------
|
|
228
|
+
float
|
|
229
|
+
It will return the atomic percentage based on the given inputs.
|
|
230
|
+
'''
|
|
231
|
+
if Entry=='mole':
|
|
232
|
+
if output=='AP_1': #atomic percent for first atom
|
|
233
|
+
AP_1=(n_1)/(n_1+n_2+n_3+n_4)
|
|
234
|
+
return AP_1
|
|
235
|
+
elif output=='AP_2': #atomic percent for second atom
|
|
236
|
+
AP_2=(n_2)/(n_1+n_2+n_3+n_4)
|
|
237
|
+
return AP_2
|
|
238
|
+
elif output=='AP_3': #atomic percent for third atom
|
|
239
|
+
AP_3=(n_3)/(n_1+n_2+n_3+n_4)
|
|
240
|
+
return AP_3
|
|
241
|
+
elif output=='Ap_4': #atomic percent for fourth atom
|
|
242
|
+
AP_4=(n_4)/(n_1+n_2+n_3+n_4)
|
|
243
|
+
return AP_4
|
|
244
|
+
if Entry=='mass':
|
|
245
|
+
if output=='AP_1':
|
|
246
|
+
AP_1=(m_1/M_1)/((m_1/M_1)+(m_2/M_2)+(m_3/M_3)+(m_4/M_4))
|
|
247
|
+
return AP_1
|
|
248
|
+
if output=='AP_2':
|
|
249
|
+
AP_2=(m_2/M_2)/((m_1/M_1)+(m_2/M_2)+(m_3/M_3)+(m_4/M_4))
|
|
250
|
+
return AP_2
|
|
251
|
+
if output=='AP_3':
|
|
252
|
+
AP_3=(m_3/M_3)/((m_1/M_1)+(m_2/M_2)+(m_3/M_3)+(m_4/M_4))
|
|
253
|
+
return AP_3
|
|
254
|
+
if output=='AP_4':
|
|
255
|
+
AP_4=(m_4/M_4)/((m_1/M_1)+(m_2/M_2)+(m_3/M_3)+(m_4/M_4))
|
|
256
|
+
return AP_4
|
|
257
|
+
if Entry=='weight':
|
|
258
|
+
if output=='AP_1':
|
|
259
|
+
AP_1=(w_1/M_1)/((w_1/M_1)+(w_2/M_2)+(w_3/M_3)+(w_4/M_4))
|
|
260
|
+
return AP_1
|
|
261
|
+
if output=='AP_2':
|
|
262
|
+
AP_2=(w_2/M_2)/((w_1/M_1)+(w_2/M_2)+(w_3/M_3)+(w_4/M_4))
|
|
263
|
+
return AP_2
|
|
264
|
+
if output=='AP_3':
|
|
265
|
+
AP_3=(w_3/M_3)/((w_1/M_1)+(w_2/M_2)+(w_3/M_3)+(w_4/M_4))
|
|
266
|
+
return AP_3
|
|
267
|
+
if output=='AP_4':
|
|
268
|
+
AP_4=(w_4/M_4)/((w_1/M_1)+(w_2/M_2)+(w_3/M_3)+(w_4/M_4))
|
|
269
|
+
return AP_4
|
|
270
|
+
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
def Austenite_Martensite_VC(C):
|
|
275
|
+
'''
|
|
276
|
+
This function calaculates the volume change of a unit cell in Austenite to Marteniste transformation.
|
|
277
|
+
|
|
278
|
+
Parameters
|
|
279
|
+
----------
|
|
280
|
+
C : float
|
|
281
|
+
C is the percentage of carbon in chemical composition of steel.
|
|
282
|
+
|
|
283
|
+
Returns
|
|
284
|
+
-------
|
|
285
|
+
VC : float
|
|
286
|
+
VC is the percentage of volume change of a unit cell in Austenite to Marteniste transformation.
|
|
287
|
+
|
|
288
|
+
'''
|
|
289
|
+
a0 = 3.548 + (0.044 * C) #Austenite lattice parameter
|
|
290
|
+
V0 = (a0 ** 3) / 2 #Volume of Austenite unit cell (FCC)
|
|
291
|
+
a = 2.861 - (0.013 * C) #Martensite lattice parameter
|
|
292
|
+
c = 2.861 + (0.116 * C) #Martensite lattice parameter
|
|
293
|
+
V=c * (a ** 2) #Volume of Martensite unit cell (BCT)
|
|
294
|
+
Delta_V = V - V0
|
|
295
|
+
VC = (Delta_V / V0) * 100
|
|
296
|
+
return VC
|
|
297
|
+
|
|
298
|
+
|
|
299
|
+
|
|
300
|
+
|
|
301
|
+
|
|
302
|
+
def BMI_Calculation(W,H):
|
|
303
|
+
'''
|
|
304
|
+
|
|
305
|
+
This function calculates body mass index
|
|
306
|
+
Parameters
|
|
307
|
+
----------
|
|
308
|
+
W : float
|
|
309
|
+
Weight in kilograms
|
|
310
|
+
H : float
|
|
311
|
+
height in meters
|
|
312
|
+
|
|
313
|
+
Returns
|
|
314
|
+
float
|
|
315
|
+
BMI_Calculation
|
|
316
|
+
|
|
317
|
+
'''
|
|
318
|
+
return(W/H**2)
|
|
319
|
+
|
|
320
|
+
|
|
321
|
+
|
|
322
|
+
|
|
323
|
+
|
|
324
|
+
def Biomaterial_Degredation_Rate(W1,W2,T):
|
|
325
|
+
'''
|
|
326
|
+
This function calculates the degradation rate of biomaterials
|
|
327
|
+
|
|
328
|
+
Parameters
|
|
329
|
+
----------
|
|
330
|
+
W1 : int
|
|
331
|
+
initial mass
|
|
332
|
+
W2 : int
|
|
333
|
+
final mass
|
|
334
|
+
T : int
|
|
335
|
+
time of degredation
|
|
336
|
+
|
|
337
|
+
Returns
|
|
338
|
+
int
|
|
339
|
+
Biomaterial_Degredation_Rate
|
|
340
|
+
|
|
341
|
+
'''
|
|
342
|
+
return((W1-W2)/W1*100/T)
|
|
343
|
+
|
|
344
|
+
|
|
345
|
+
|
|
346
|
+
|
|
347
|
+
def Burning_Rate(L,t):##L=burning length in mm & t=burning time in sec
|
|
348
|
+
V=(60*L)/t ##V= burning rate in mm/sec according to the ASTM D3801 UL-94 test
|
|
349
|
+
return V
|
|
350
|
+
|
|
351
|
+
|
|
352
|
+
|
|
353
|
+
|
|
354
|
+
def boyles_law(initial_volume, initial_pressure, final_volume):
|
|
355
|
+
return initial_pressure * initial_volume - final_volume
|
|
356
|
+
|
|
357
|
+
|
|
358
|
+
|
|
359
|
+
|
|
360
|
+
|
|
361
|
+
def boltzmann_distribution(energy, temperature, boltzmann_constant):
|
|
362
|
+
return math.exp(-energy / (boltzmann_constant * temperature))
|
|
363
|
+
|
|
364
|
+
|
|
365
|
+
|
|
366
|
+
|
|
367
|
+
def Bragg_Law (h,k,l,a,y):
|
|
368
|
+
'''
|
|
369
|
+
This function calculate the diffraction angle of a incidence wavelenght through a crytal special plate
|
|
370
|
+
|
|
371
|
+
Parameters
|
|
372
|
+
----------
|
|
373
|
+
h : int
|
|
374
|
+
x direction of the plate.
|
|
375
|
+
k : int
|
|
376
|
+
y direction of the plate.
|
|
377
|
+
l : int
|
|
378
|
+
z direction of the plate.
|
|
379
|
+
a : float
|
|
380
|
+
Unit Cell.
|
|
381
|
+
y : float
|
|
382
|
+
incidence wavelenght.
|
|
383
|
+
|
|
384
|
+
'''
|
|
385
|
+
square_sin_teta=(((y**2)*((h**2)+(k**2)+(l**2))))/4*a**2
|
|
386
|
+
teta=math.asin((square_sin_teta)**1/2)
|
|
387
|
+
|
|
388
|
+
return teta*180/math.pi
|
|
389
|
+
|
|
390
|
+
|
|
391
|
+
|
|
392
|
+
|
|
393
|
+
|
|
394
|
+
def Berag_law(landa,sin_a):
|
|
395
|
+
"""
|
|
396
|
+
Parameters
|
|
397
|
+
landa( float) is wavelength in micro meters
|
|
398
|
+
sin_a (float)is the sine of defraction angle/2
|
|
399
|
+
Berag's law is landa=2dsin_a
|
|
400
|
+
Returns d (float) value which is the distance between
|
|
401
|
+
two atomic planes responsible for the defraction in micron
|
|
402
|
+
"""
|
|
403
|
+
d=landa/(2*sin_a)
|
|
404
|
+
return d
|
|
405
|
+
|
|
406
|
+
|
|
407
|
+
|
|
408
|
+
def Beer_Lambert_Law (a,l,I0):
|
|
409
|
+
'''
|
|
410
|
+
This function caclculate the output light intensity when a light pass through a material
|
|
411
|
+
Parameters
|
|
412
|
+
----------
|
|
413
|
+
a : float
|
|
414
|
+
absorption coefficient.
|
|
415
|
+
l : float
|
|
416
|
+
length.
|
|
417
|
+
I0 : float
|
|
418
|
+
incomming light intensity.
|
|
419
|
+
|
|
420
|
+
Returns
|
|
421
|
+
-------
|
|
422
|
+
I : float
|
|
423
|
+
output light intensity.
|
|
424
|
+
|
|
425
|
+
'''
|
|
426
|
+
I=I0*(10**(-a*l))
|
|
427
|
+
return I
|
|
428
|
+
|
|
429
|
+
|
|
430
|
+
|
|
431
|
+
|
|
432
|
+
def Binomial_Probability(n,k,p):
|
|
433
|
+
"""
|
|
434
|
+
|
|
435
|
+
|
|
436
|
+
Parameters
|
|
437
|
+
----------
|
|
438
|
+
p :float
|
|
439
|
+
ehtemal voghoo beyn 0ta 1
|
|
440
|
+
n:int
|
|
441
|
+
tedad dafat azmayesh
|
|
442
|
+
K:int
|
|
443
|
+
tedad dafaat bord
|
|
444
|
+
|
|
445
|
+
return ehtemal rokh dadan pishamad dar fazaye do pishamadi(bord,shekast)
|
|
446
|
+
ba tedad n azmayesh va tedad k bord
|
|
447
|
+
|
|
448
|
+
|
|
449
|
+
"""
|
|
450
|
+
q=1-p
|
|
451
|
+
return p**k*q**(n-k)
|
|
452
|
+
|
|
453
|
+
|
|
454
|
+
|
|
455
|
+
|
|
456
|
+
def Bouyancy_Force(d,V):
|
|
457
|
+
g=9.81#(m/s^2)
|
|
458
|
+
F_b=d*g*V
|
|
459
|
+
return F_b
|
|
460
|
+
|
|
461
|
+
|
|
462
|
+
|
|
463
|
+
|
|
464
|
+
|
|
465
|
+
def Brinell_Hardness_Calculation (d1,d2,D,p):
|
|
466
|
+
|
|
467
|
+
'''
|
|
468
|
+
this function is utilized for calculating Brinell hardness.
|
|
469
|
+
characterizes the indentation hardness of materials through the
|
|
470
|
+
scale of penetration of an indenter, loaded on a material test-piece.
|
|
471
|
+
It is one of several definitions of hardness in materials science.
|
|
472
|
+
In this method, steel ball indentor is used.
|
|
473
|
+
|
|
474
|
+
Parameters
|
|
475
|
+
-----------
|
|
476
|
+
1. d1: float
|
|
477
|
+
d1 represents diameter of impress of indentor.
|
|
478
|
+
|
|
479
|
+
2. d2 : float
|
|
480
|
+
d2 represents diameter of impress of indentor
|
|
481
|
+
|
|
482
|
+
3. D : float
|
|
483
|
+
diameter of indenter
|
|
484
|
+
|
|
485
|
+
3. p : int
|
|
486
|
+
applied load
|
|
487
|
+
|
|
488
|
+
Returns --> BHN (Brinell Hardness Number)
|
|
489
|
+
'''
|
|
490
|
+
|
|
491
|
+
d = (d1+d2)/2
|
|
492
|
+
BHN = (2*p)/(3.14*D)(D-(math.sqrt(D**2 - d**2)))
|
|
493
|
+
|
|
494
|
+
return BHN
|
|
495
|
+
|
|
496
|
+
|
|
497
|
+
|
|
498
|
+
|
|
499
|
+
|
|
500
|
+
|
|
501
|
+
|
|
502
|
+
|
|
503
|
+
|
|
504
|
+
|
|
505
|
+
def Corrosion_Rate(W,D,A,t):
|
|
506
|
+
'''
|
|
507
|
+
|
|
508
|
+
|
|
509
|
+
Parameters
|
|
510
|
+
----------
|
|
511
|
+
W : int or float
|
|
512
|
+
The change in weight of specimen (mg)
|
|
513
|
+
D : int or float
|
|
514
|
+
The density of specimen (g/cm^3)
|
|
515
|
+
A : int or float
|
|
516
|
+
The surface area of specimen (in^2)
|
|
517
|
+
t : int or float
|
|
518
|
+
The time(h)
|
|
519
|
+
|
|
520
|
+
Returns
|
|
521
|
+
-------
|
|
522
|
+
CR : int or float
|
|
523
|
+
The corrosion rate (mpy)
|
|
524
|
+
|
|
525
|
+
'''
|
|
526
|
+
|
|
527
|
+
CR=534.6*W/(D*A*t)
|
|
528
|
+
return CR
|
|
529
|
+
|
|
530
|
+
|
|
531
|
+
|
|
532
|
+
|
|
533
|
+
def Calculate_ECB(chi, Ee, Eg):
|
|
534
|
+
|
|
535
|
+
'''
|
|
536
|
+
This function calculates the conduction band edge energy (ECB) of a semiconductor using Mulliken electronegativity theory.
|
|
537
|
+
|
|
538
|
+
Parameters
|
|
539
|
+
----------
|
|
540
|
+
chi : float
|
|
541
|
+
The absolute electronegativity of the semiconductor (eV), calculated as the geometric mean of the absolute electronegativity
|
|
542
|
+
of the constituent elements. For ZnO, chi=sqrt(chi_Zn*chi_O)=5.79 eV.
|
|
543
|
+
|
|
544
|
+
Ee : float
|
|
545
|
+
The energy of free electrons on the standard hydrogen electrode (SHE) scale (eV). For standard scale, Ee=4.5 eV.
|
|
546
|
+
|
|
547
|
+
Eg : float
|
|
548
|
+
The bandgap energy of the semiconductor (eV). For ZnO, Eg=3.23 eV.
|
|
549
|
+
|
|
550
|
+
Returns
|
|
551
|
+
-------
|
|
552
|
+
ECB : float
|
|
553
|
+
The conduction band edge energy (eV).
|
|
554
|
+
|
|
555
|
+
'''
|
|
556
|
+
|
|
557
|
+
ECB=chi-Ee+0.5*Eg
|
|
558
|
+
|
|
559
|
+
return (ECB)
|
|
560
|
+
|
|
561
|
+
|
|
562
|
+
|
|
563
|
+
|
|
564
|
+
|
|
565
|
+
|
|
566
|
+
def Circle_Area(radius):
|
|
567
|
+
'''
|
|
568
|
+
|
|
569
|
+
|
|
570
|
+
Parameters
|
|
571
|
+
----------
|
|
572
|
+
radius : int
|
|
573
|
+
radius of circle.
|
|
574
|
+
|
|
575
|
+
Returns
|
|
576
|
+
-------
|
|
577
|
+
circle_area:int
|
|
578
|
+
area of circle.
|
|
579
|
+
|
|
580
|
+
'''
|
|
581
|
+
circle_area=(radius**2)*math.pi
|
|
582
|
+
return circle_area
|
|
583
|
+
|
|
584
|
+
|
|
585
|
+
|
|
586
|
+
|
|
587
|
+
def Circle_Perimeter(radius):
|
|
588
|
+
'''
|
|
589
|
+
|
|
590
|
+
|
|
591
|
+
Parameters
|
|
592
|
+
----------
|
|
593
|
+
radius : int
|
|
594
|
+
radius of circle.
|
|
595
|
+
|
|
596
|
+
Returns
|
|
597
|
+
-------
|
|
598
|
+
circle_perimeter: int
|
|
599
|
+
perimeter of circle.
|
|
600
|
+
|
|
601
|
+
'''
|
|
602
|
+
circle_perimeter=2*math.pi*radius
|
|
603
|
+
return circle_perimeter
|
|
604
|
+
|
|
605
|
+
|
|
606
|
+
|
|
607
|
+
|
|
608
|
+
|
|
609
|
+
|
|
610
|
+
def coulombs_law(charge1, charge2, distance):
|
|
611
|
+
k_constant = 8.9875e9 # Coulomb's constant
|
|
612
|
+
return k_constant * (charge1 * charge2) / distance**2
|
|
613
|
+
|
|
614
|
+
|
|
615
|
+
|
|
616
|
+
|
|
617
|
+
|
|
618
|
+
|
|
619
|
+
def Convert_Gas_Constant(gas_constant , from_unit , to_unit):
|
|
620
|
+
|
|
621
|
+
conversion_factors = {
|
|
622
|
+
"J/mol.K": {
|
|
623
|
+
"J/mol.K": 1 ,
|
|
624
|
+
"cal/mol.K": 0.239 ,
|
|
625
|
+
"atm.L/mol.K": 8.314 ,
|
|
626
|
+
"cm^3.atm/mol.K": 82.057 ,
|
|
627
|
+
} ,
|
|
628
|
+
"cal/mol.K": {
|
|
629
|
+
"J/mol.K": 4.184 ,
|
|
630
|
+
"cal/mol.K": 1 ,
|
|
631
|
+
"atm.L/mol.K": 24.205 ,
|
|
632
|
+
"cm^3/mol.K": 239.006 ,
|
|
633
|
+
} ,
|
|
634
|
+
"atm.L/mol.K": {
|
|
635
|
+
"J/mol.K": 0.0821 ,
|
|
636
|
+
"cal/mol.K": 0.042 ,
|
|
637
|
+
"atm.L/mol.K": 1 ,
|
|
638
|
+
"cm^3/mol.K": 10
|
|
639
|
+
} ,
|
|
640
|
+
"cm^3/mol.K": {
|
|
641
|
+
"J/mol.K": 0.001987 ,
|
|
642
|
+
"cal/mol.K": 0.0042 ,
|
|
643
|
+
"atm.L/mol.K": 0.1 ,
|
|
644
|
+
"cm^3/mol.K": 1
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
if from_unit in conversion_factors and to_unit in conversion_factors[from_unit]:
|
|
649
|
+
conversion_factors = conversion_factors[from_unit][to_unit]
|
|
650
|
+
converted_value = gas_constant * conversion_factors
|
|
651
|
+
|
|
652
|
+
return converted_value
|
|
653
|
+
|
|
654
|
+
else:
|
|
655
|
+
return "Invalid"
|
|
656
|
+
|
|
657
|
+
|
|
658
|
+
|
|
659
|
+
|
|
660
|
+
|
|
661
|
+
def Carnot_Efficiency(T_c , T_h):
|
|
662
|
+
|
|
663
|
+
'''
|
|
664
|
+
Parameters
|
|
665
|
+
----------
|
|
666
|
+
|
|
667
|
+
T_hot (float): Hot source temperature (Kelvin)
|
|
668
|
+
T_cold (float): Cold source temperature (Kelvin)
|
|
669
|
+
|
|
670
|
+
Returns:
|
|
671
|
+
float : Efficiency of the cycle
|
|
672
|
+
|
|
673
|
+
'''
|
|
674
|
+
try:
|
|
675
|
+
if T_h <= 0 or T_c <=0:
|
|
676
|
+
raise ValueError("Temperature must be +!")
|
|
677
|
+
efficiency = 1 - (T_c / T_h)
|
|
678
|
+
return efficiency
|
|
679
|
+
|
|
680
|
+
except ValueError as e:
|
|
681
|
+
print(f"ERROR: {e}")
|
|
682
|
+
|
|
683
|
+
|
|
684
|
+
|
|
685
|
+
|
|
686
|
+
|
|
687
|
+
|
|
688
|
+
|
|
689
|
+
def Contact_Angle(num1,num2,num3):
|
|
690
|
+
'''
|
|
691
|
+
|
|
692
|
+
|
|
693
|
+
Parameters
|
|
694
|
+
----------
|
|
695
|
+
num1 : float
|
|
696
|
+
a solid and atmospher surface tenssion.
|
|
697
|
+
num2 : float
|
|
698
|
+
a liquid and atmospher surface tension.
|
|
699
|
+
num3 : float
|
|
700
|
+
a solid and liquid boundary tension.
|
|
701
|
+
|
|
702
|
+
Returns
|
|
703
|
+
degrees
|
|
704
|
+
|
|
705
|
+
'''
|
|
706
|
+
|
|
707
|
+
costeta= (num1-num3)/num2
|
|
708
|
+
teta = math.acos(costeta)
|
|
709
|
+
teta_degree= teta*180/math.pi
|
|
710
|
+
return teta_degree
|
|
711
|
+
|
|
712
|
+
|
|
713
|
+
|
|
714
|
+
|
|
715
|
+
|
|
716
|
+
|
|
717
|
+
|
|
718
|
+
def Copolymer_Type(Copolymer, Polymer_num=2):
|
|
719
|
+
'''
|
|
720
|
+
Copolymer: str
|
|
721
|
+
Unit types are shown by charachters which are seperated by a space
|
|
722
|
+
Example: 'polymer_A polymer_A polymer_B polymer_A polymer_A polymer_B'
|
|
723
|
+
|
|
724
|
+
Polymer_num: int
|
|
725
|
+
It represents the number of polymers in this structure which could be 2 or 3
|
|
726
|
+
default = 2
|
|
727
|
+
'''
|
|
728
|
+
valid = [2, 3]
|
|
729
|
+
if Polymer_num not in valid:
|
|
730
|
+
raise ValueError('Polymer_num should be 2 or 3')
|
|
731
|
+
|
|
732
|
+
co_list = Copolymer.split()
|
|
733
|
+
change = []
|
|
734
|
+
unique = 0
|
|
735
|
+
unique_list = []
|
|
736
|
+
for i in range(1,len(co_list)):
|
|
737
|
+
if co_list[i-1] not in unique_list:
|
|
738
|
+
unique_list.append(co_list[i-1])
|
|
739
|
+
unique += 1
|
|
740
|
+
if co_list[i] != co_list[i-1]:
|
|
741
|
+
change.append(True)
|
|
742
|
+
else:
|
|
743
|
+
change.append(False)
|
|
744
|
+
|
|
745
|
+
if change.count(True) == 0:
|
|
746
|
+
print('Error: It is not a copolymer')
|
|
747
|
+
elif Polymer_num != unique:
|
|
748
|
+
print('Error: The number of unique units in the copolymer is not compatible with the Polymer_num entered')
|
|
749
|
+
elif Polymer_num == 2:
|
|
750
|
+
if change.count(False) == 0:
|
|
751
|
+
copolymer_type = 'Alternative'
|
|
752
|
+
print(copolymer_type)
|
|
753
|
+
elif change.count(True)==1:
|
|
754
|
+
copolymer_type = 'Block'
|
|
755
|
+
print(copolymer_type)
|
|
756
|
+
else:
|
|
757
|
+
copolymer_type = 'Random'
|
|
758
|
+
print(copolymer_type)
|
|
759
|
+
return copolymer_type
|
|
760
|
+
|
|
761
|
+
|
|
762
|
+
|
|
763
|
+
|
|
764
|
+
|
|
765
|
+
|
|
766
|
+
def Cost_Indicators(ac,ev):
|
|
767
|
+
|
|
768
|
+
global cv,cpi
|
|
769
|
+
cv=ev-ac
|
|
770
|
+
cpi=ev/ac
|
|
771
|
+
|
|
772
|
+
return cv,cpi
|
|
773
|
+
|
|
774
|
+
|
|
775
|
+
|
|
776
|
+
|
|
777
|
+
|
|
778
|
+
def Crystal_Percent(H,W,H100):#H=polymer enthalpy in mJ & W=polymer weight in mg & H100=neede enthalpy for polymer with 100%crystallinity in j/gr
|
|
779
|
+
Xc=((H/W)/H100)*100 #Xc=polymer crystallinity in %
|
|
780
|
+
return Xc
|
|
781
|
+
|
|
782
|
+
|
|
783
|
+
|
|
784
|
+
def Calculate_Pipe_Heat_Transfer(mu,muW,rho,Cp,Pr,K,u,d,l,Tw,Tb1):
|
|
785
|
+
'''
|
|
786
|
+
Parameters
|
|
787
|
+
----------
|
|
788
|
+
mu : float
|
|
789
|
+
Fluid dynamic viscosity (pa.s).
|
|
790
|
+
muW : float
|
|
791
|
+
Dynamic viscosity at wall temperature (pa.s).
|
|
792
|
+
rho : float
|
|
793
|
+
fluid density (kg/m³).
|
|
794
|
+
Cp : float
|
|
795
|
+
DESCRIPTION.
|
|
796
|
+
Pr : float
|
|
797
|
+
Prantel number.
|
|
798
|
+
K : flout
|
|
799
|
+
Thermal conductivity(W/m.K).
|
|
800
|
+
u : float
|
|
801
|
+
fluid velocity (m/s).
|
|
802
|
+
d : float
|
|
803
|
+
Pipe diameter (m).
|
|
804
|
+
L : float
|
|
805
|
+
Pipe length (m).
|
|
806
|
+
Tw : float
|
|
807
|
+
Pipe wall temperature.
|
|
808
|
+
Tb1 : float
|
|
809
|
+
Average fluid temperature().
|
|
810
|
+
|
|
811
|
+
Returns
|
|
812
|
+
Reynolds number, Nusselt number, convective heat transfer coefficient, total heat transfer, and outlet temperature.
|
|
813
|
+
-------
|
|
814
|
+
None.
|
|
815
|
+
|
|
816
|
+
'''
|
|
817
|
+
########################
|
|
818
|
+
#توضیحات کد: ابتدا عدد رینولدز محاسبه میگرد، اگر که کمتر از 2000 باشد در این صورت جریان آرام است .
|
|
819
|
+
# برای جریان آرام داخل لوله اگر لوله طویل باشد عدد ناسلت 3.66 می شود و اکر لوله طویل نباشد از فرمول ناسلت نوشته شده (1) استفاده می گردد .
|
|
820
|
+
#و اگر عدد رینولدز در بازه ی 2500-1.25ضرب در 10 به توان 5 باشد و عدد پرانتل در بازه ی ذکر شده باشد ،از فرمول 2 استفاده می شود در صورتی که برای n تگر دمای جداره بیشتر از دمای سیال باشد برابر 0.4 .
|
|
821
|
+
# حالا می خواهیم با استفاده از عدد ناسلت ضریب انتقال حرارت جابه جایی را بدست آوریم .
|
|
822
|
+
# و ضریب انتقال حرارنت جابه جایی را حساب نموده و با استفاده از تساوی آخر دمای خروجی سیال بدست می آید .
|
|
823
|
+
########################
|
|
824
|
+
|
|
825
|
+
Re=(rho*u*d)/mu
|
|
826
|
+
if Re<2000:
|
|
827
|
+
print('flow type laminar')
|
|
828
|
+
if (Re*Pr*(d/l))>10:
|
|
829
|
+
Nu=1.86*(Re*Pr)**(1/3)*(d/l)**(1/3)*(mu/muW)**0.14#####برای لوله های طویل صادق نیست(1) .
|
|
830
|
+
else:
|
|
831
|
+
Nu=3.66####برای لوله های طویل و دمای ثابت در جداره لوله
|
|
832
|
+
elif 2500<Re<(1.25*(10**5)) and 1.5<Pr<100:
|
|
833
|
+
print('flow type Turbulent')
|
|
834
|
+
if Tw>Tb1:
|
|
835
|
+
n=0.4
|
|
836
|
+
else:
|
|
837
|
+
n=0.3
|
|
838
|
+
Nu=(0.023*(Re**0.8)*(Pr**n))##(2)
|
|
839
|
+
else:
|
|
840
|
+
return None
|
|
841
|
+
h = (Nu * K) / d
|
|
842
|
+
A=3.14*d*l
|
|
843
|
+
Tb2 =Tb1+(h*A*(Tw-Tb1))/(rho*Cp*u)
|
|
844
|
+
Q=((rho*A*u)*Cp*(Tb2-Tb1))
|
|
845
|
+
return {Re,Nu,h,Q,Tb2}
|
|
846
|
+
|
|
847
|
+
|
|
848
|
+
|
|
849
|
+
|
|
850
|
+
|
|
851
|
+
|
|
852
|
+
def Cohen(m,r,/):
|
|
853
|
+
'''
|
|
854
|
+
Cohen equation is used to predict the yield stress of a polymeric blend containing a rubbery dispersion phase.
|
|
855
|
+
|
|
856
|
+
Parameters
|
|
857
|
+
----------
|
|
858
|
+
m : int or float
|
|
859
|
+
The yield stress of polymeric matrix, N/m^2 or Pa or ...
|
|
860
|
+
r : float
|
|
861
|
+
Volume fraction of rubbery phase, 0<r<1.
|
|
862
|
+
|
|
863
|
+
Returns
|
|
864
|
+
-------
|
|
865
|
+
b : int or float
|
|
866
|
+
The yield stress of polymeric blend, N/m^2 or Pa or ...
|
|
867
|
+
|
|
868
|
+
'''
|
|
869
|
+
a=(1-1.21*math.pow(r,(2/3)))
|
|
870
|
+
b=m*a
|
|
871
|
+
return b
|
|
872
|
+
|
|
873
|
+
|
|
874
|
+
|
|
875
|
+
|
|
876
|
+
|
|
877
|
+
def Critical_Diameter(d,r,/):
|
|
878
|
+
'''
|
|
879
|
+
This equation predicts the critical diameter of rubber particles toughening a polymeric matrix.
|
|
880
|
+
Parameters
|
|
881
|
+
----------
|
|
882
|
+
d : int or float
|
|
883
|
+
critical distance between rubbery particles, angstrom or mm or nm or .....
|
|
884
|
+
r : float
|
|
885
|
+
Volume fraction of rubbery phase, 0<r<1.
|
|
886
|
+
|
|
887
|
+
Returns
|
|
888
|
+
-------
|
|
889
|
+
dc : int or float
|
|
890
|
+
the critical diameter of rubber particles
|
|
891
|
+
|
|
892
|
+
'''
|
|
893
|
+
a=6*math.pow(r,(1/3))
|
|
894
|
+
b=a-1
|
|
895
|
+
c=3.14/b
|
|
896
|
+
dc=d/c
|
|
897
|
+
return dc
|
|
898
|
+
|
|
899
|
+
|
|
900
|
+
|
|
901
|
+
|
|
902
|
+
|
|
903
|
+
def Component(a,b):
|
|
904
|
+
'''
|
|
905
|
+
تصویر اسکالر b بر a
|
|
906
|
+
(اندازه بردار تصویر)
|
|
907
|
+
|
|
908
|
+
Parameters
|
|
909
|
+
----------
|
|
910
|
+
a : list
|
|
911
|
+
multi-dimensional vector
|
|
912
|
+
b : list
|
|
913
|
+
multi-dimensional vector
|
|
914
|
+
|
|
915
|
+
Returns
|
|
916
|
+
-------
|
|
917
|
+
c : float
|
|
918
|
+
The component of b on a
|
|
919
|
+
|
|
920
|
+
'''
|
|
921
|
+
ab=0
|
|
922
|
+
aa=0
|
|
923
|
+
for i in range(0,len(a)):
|
|
924
|
+
ab=ab+a[i]*b[i]
|
|
925
|
+
aa=aa+a[i]*a[i]
|
|
926
|
+
aas=math.sqrt(aa)
|
|
927
|
+
c=(ab/aas)
|
|
928
|
+
return c
|
|
929
|
+
|
|
930
|
+
|
|
931
|
+
|
|
932
|
+
|
|
933
|
+
|
|
934
|
+
def Change_In_Pressure_Of_a_Mercury_OR_Water_Column_Manometer(Type_Of_Fluid,h,g=9.81):
|
|
935
|
+
|
|
936
|
+
if Type_Of_Fluid.upper()=='water':
|
|
937
|
+
Delta_P=1*h*g
|
|
938
|
+
return Delta_P
|
|
939
|
+
|
|
940
|
+
if Type_Of_Fluid.upper()=='mercury':
|
|
941
|
+
Delta_P=13.6*h*g
|
|
942
|
+
return Delta_P
|
|
943
|
+
|
|
944
|
+
else:
|
|
945
|
+
raise ValueError ("Invalid Type of Fluid")
|
|
946
|
+
|
|
947
|
+
|
|
948
|
+
|
|
949
|
+
|
|
950
|
+
def Concentration_Calculator (CA1, unit_CA1, CA2, unit_CA2, Q1, unit_Q1, Q2, unit_Q2):
|
|
951
|
+
'''
|
|
952
|
+
Parameters
|
|
953
|
+
----------
|
|
954
|
+
CA1 : float
|
|
955
|
+
Concentratoion of the first flow
|
|
956
|
+
unit_CA1: str
|
|
957
|
+
Unit of concentratoion of the first flow
|
|
958
|
+
CA2 : float
|
|
959
|
+
DESCRIPTION.Concentratoion of the second flow
|
|
960
|
+
unit_CA2: str
|
|
961
|
+
Unit of concentratoion of the second flow
|
|
962
|
+
Q1 : float
|
|
963
|
+
Molar volume of the first flow
|
|
964
|
+
unit_Q1: str
|
|
965
|
+
Unit of molar volume of the first flow
|
|
966
|
+
Q2 : float
|
|
967
|
+
Molar volume of the second flow
|
|
968
|
+
unit_Q2: str
|
|
969
|
+
Unit of molar volume of the second flow
|
|
970
|
+
|
|
971
|
+
Returns
|
|
972
|
+
-------
|
|
973
|
+
Flowrate and concentration of the output flow
|
|
974
|
+
'''
|
|
975
|
+
|
|
976
|
+
if unit_CA1== 'mole/lit':
|
|
977
|
+
CA1= CA1*1000
|
|
978
|
+
elif unit_CA1== 'mole/ml':
|
|
979
|
+
CA1= CA1*1000000
|
|
980
|
+
|
|
981
|
+
if unit_CA2== 'mole/lit':
|
|
982
|
+
CA2= CA2*1000
|
|
983
|
+
elif unit_CA2== 'mole/ml':
|
|
984
|
+
CA2= CA2*1000000
|
|
985
|
+
|
|
986
|
+
if unit_Q1== 'lit':
|
|
987
|
+
Q1= Q1/1000
|
|
988
|
+
elif unit_Q1== 'ml' or unit_Q1== 'cc':
|
|
989
|
+
Q1= Q1/1000000
|
|
990
|
+
|
|
991
|
+
if unit_Q2== 'lit':
|
|
992
|
+
Q2= Q2/1000
|
|
993
|
+
elif unit_Q2== 'ml' or unit_Q2== 'cc':
|
|
994
|
+
Q2= Q2/1000000
|
|
995
|
+
|
|
996
|
+
V_out = Q1+Q2
|
|
997
|
+
C_out= (CA1*Q1 + CA2*Q2)/V_out
|
|
998
|
+
return V_out
|
|
999
|
+
return C_out
|
|
1000
|
+
|
|
1001
|
+
|
|
1002
|
+
|
|
1003
|
+
|
|
1004
|
+
|
|
1005
|
+
|
|
1006
|
+
def Density(m, V):
|
|
1007
|
+
'''
|
|
1008
|
+
It's the formula for obtaining density.
|
|
1009
|
+
|
|
1010
|
+
Parameters:
|
|
1011
|
+
----------
|
|
1012
|
+
m : float
|
|
1013
|
+
Mass
|
|
1014
|
+
|
|
1015
|
+
V: float
|
|
1016
|
+
volume
|
|
1017
|
+
'''
|
|
1018
|
+
den = m / V
|
|
1019
|
+
return den
|
|
1020
|
+
|
|
1021
|
+
|
|
1022
|
+
|
|
1023
|
+
|
|
1024
|
+
def Drag_Force(Velocity,Fluid_Coefficent,Fluid_Density,cross_sectional_area,):
|
|
1025
|
+
D = ((Velocity**2)*(Fluid_Density)*(Fluid_Coefficent)*(cross_sectional_area))/2
|
|
1026
|
+
return D
|
|
1027
|
+
|
|
1028
|
+
|
|
1029
|
+
|
|
1030
|
+
|
|
1031
|
+
|
|
1032
|
+
def Degradation_Percentage(C0,Ct):
|
|
1033
|
+
|
|
1034
|
+
'''
|
|
1035
|
+
This function calculates the degradation percentage of a pollutant solution in a photocatalytic process.
|
|
1036
|
+
|
|
1037
|
+
Parameters
|
|
1038
|
+
----------
|
|
1039
|
+
C0: float
|
|
1040
|
+
Initial concentration of the pollutant solution (mg/L)
|
|
1041
|
+
|
|
1042
|
+
Ct: float
|
|
1043
|
+
Concentration of the pollutant solution at a certain time interval (mg/L)
|
|
1044
|
+
|
|
1045
|
+
Returns
|
|
1046
|
+
-------
|
|
1047
|
+
Percentage: float
|
|
1048
|
+
The degradation percentage (%) of the pollutant solution.
|
|
1049
|
+
|
|
1050
|
+
'''
|
|
1051
|
+
|
|
1052
|
+
Percentage=(1-(Ct/ C0))*100
|
|
1053
|
+
|
|
1054
|
+
return (Percentage)
|
|
1055
|
+
|
|
1056
|
+
|
|
1057
|
+
|
|
1058
|
+
|
|
1059
|
+
def darcys_law(flow_rate, permeability, area, pressure_difference):
|
|
1060
|
+
return permeability * area * pressure_difference - flow_rate
|
|
1061
|
+
|
|
1062
|
+
|
|
1063
|
+
|
|
1064
|
+
|
|
1065
|
+
|
|
1066
|
+
def doppler_effect(observed_frequency, source_frequency, velocity_observer, velocity_source, speed_of_sound):
|
|
1067
|
+
return observed_frequency - source_frequency * ((speed_of_sound + velocity_observer) / (speed_of_sound - velocity_source))
|
|
1068
|
+
|
|
1069
|
+
|
|
1070
|
+
|
|
1071
|
+
|
|
1072
|
+
|
|
1073
|
+
def Diffusivity(MA, MB, T, rAB, K, εAB, f, Pt=1.013*10**5):
|
|
1074
|
+
|
|
1075
|
+
M = { 'Carbon' '(C)': 0.01201, #kg/kmol
|
|
1076
|
+
'Hydrogen' '(H)': 0.001008, #kg/kmol
|
|
1077
|
+
'Chlorine' '(Cl)': 0.03545, #kg/kmol
|
|
1078
|
+
'Bromine' '(Br)': 0.07990, #kg/kmol
|
|
1079
|
+
'Iodine' '(I)': 0.12690, #kg/kmol
|
|
1080
|
+
'Sulfur' '(S)': 0.03207, #kg/kmol
|
|
1081
|
+
'Nitrogen' '(N)': 0.01401, #kg/kmol
|
|
1082
|
+
'H2': 0.002016, #kg/kmol
|
|
1083
|
+
'O2': 0.03200, #kg/kmol
|
|
1084
|
+
'N2': 0.02802, #kg/kmol
|
|
1085
|
+
'Air': 28.97, #kg/kmol for dry air
|
|
1086
|
+
'CO': 0.02801, #kg/kmol
|
|
1087
|
+
'CO2': 0.04401, #kg/kmol
|
|
1088
|
+
'SO2': 0.06407, #kg/kmol
|
|
1089
|
+
'NO': 0.03001, #kg/kmol
|
|
1090
|
+
'N2O': 0.04402, #kg/kmol
|
|
1091
|
+
'Oxygen': 0.03200, #kg/kmol
|
|
1092
|
+
'NH3': 0.01703, #kg/kmol
|
|
1093
|
+
'H2O': 0.01802, #kg/kmol
|
|
1094
|
+
'H2S': 0.03408, #kg/kmol
|
|
1095
|
+
'COS': 0.06007, #kg/kmol
|
|
1096
|
+
'Cl2': 0.07090, #kg/kmol
|
|
1097
|
+
'Br2': 0.15980, #kg/kmol
|
|
1098
|
+
'I2': 0.25380, #kg/kmol
|
|
1099
|
+
'C3H6O':58.08 #kg/kmol
|
|
1100
|
+
}
|
|
1101
|
+
|
|
1102
|
+
if MA in M and MB in M:
|
|
1103
|
+
AB = float(((((((1/M[MA])**0.5 + (1/M[MB])**0.5) * 0.249) - 1.084) * (10**-4)) * T**(3/2)) * ((1/M[MA])**0.5 + (1/M[MB])**0.5))
|
|
1104
|
+
DAB = float(( AB / (((rAB**2) * Pt) * ((K*T / εAB) * f)))*-1) #formula hame emtehan shode va ba data bedast amadeh be sorat mohasebeh dasti moghayeseh shodeh va ba deghat balayi javab doroost bodeh.
|
|
1105
|
+
|
|
1106
|
+
return DAB
|
|
1107
|
+
else:
|
|
1108
|
+
return "Invalid inputs"
|
|
1109
|
+
|
|
1110
|
+
|
|
1111
|
+
|
|
1112
|
+
|
|
1113
|
+
|
|
1114
|
+
def Diffusion_in_Gases(Diffusion_Type, Diffusivity, Separate_Panels_Distance, Pressure_in_Panel_A, Pressure_in_Panel_B, PressureBM, Gas_Constant, Total_Pressure=1.013*10**5):
|
|
1115
|
+
|
|
1116
|
+
|
|
1117
|
+
DAB = {'H2-CH4': 6.25*10**-5, #M**2/S
|
|
1118
|
+
'O2-N2': 1.81*10**-5,
|
|
1119
|
+
'CO-O2': 1.85*10**-5,
|
|
1120
|
+
'CO2-O2': 1.39*10**-5,
|
|
1121
|
+
'Air-NH3': 1.98*10**-5,
|
|
1122
|
+
'Air-H2O': 2.58*10**-5,
|
|
1123
|
+
'Air-ethanol': 1.02*10**-5,
|
|
1124
|
+
'Air-ethyl-acetate': 0.87*10**-5,
|
|
1125
|
+
'Air-aniline': 0.74*10**-5,
|
|
1126
|
+
'Air-chlorobenzene': 0.74*10**-5,
|
|
1127
|
+
'Air-toluene': 0.86*10**-5}
|
|
1128
|
+
|
|
1129
|
+
Temp = {'H2-CH4': 273.15, #Kelvin
|
|
1130
|
+
'O2-N2': 273.15,
|
|
1131
|
+
'CO-O2': 273.15,
|
|
1132
|
+
'CO2-O2': 273.15,
|
|
1133
|
+
'Air-NH3': 273.15,
|
|
1134
|
+
'Air-H2O': 299.05,
|
|
1135
|
+
'Air-ethanol': 299.05,
|
|
1136
|
+
'Air-ethyl-acetate': 274.2,
|
|
1137
|
+
'Air-aniline': 299.05,
|
|
1138
|
+
'Air-chlorobenzene': 299.05,
|
|
1139
|
+
'Air-toluene': 299.05}
|
|
1140
|
+
|
|
1141
|
+
# We can also write like this :
|
|
1142
|
+
|
|
1143
|
+
# if Diffusivity=='H2-CH4':
|
|
1144
|
+
# DAB=6.25*10**-5
|
|
1145
|
+
# Temp=273.15
|
|
1146
|
+
#if Diffusivity=='O2-N2':
|
|
1147
|
+
# DAB=1.81*10**-5
|
|
1148
|
+
# Temp=273.15
|
|
1149
|
+
#if Diffusivity=='CO-O2':
|
|
1150
|
+
# DAB=1.85*10**-5
|
|
1151
|
+
# Temp=273.15
|
|
1152
|
+
#if Diffusivity=='CO2-O2':
|
|
1153
|
+
# DAB=1.39*10**-5
|
|
1154
|
+
# Temp=273.15
|
|
1155
|
+
#if Diffusivity=='Air-NH3':
|
|
1156
|
+
# DAB=1.98*10**-5
|
|
1157
|
+
# Temp=273.15
|
|
1158
|
+
#if Diffusivity=='Air-H2O':
|
|
1159
|
+
# DAB=2.58*10**-5
|
|
1160
|
+
# Temp=299.05
|
|
1161
|
+
#if Diffusivity=='Air-ethanol':
|
|
1162
|
+
# DAB=1.02*10**-5
|
|
1163
|
+
# Temp=299.05
|
|
1164
|
+
#if Diffusivity=='Air-ethyl-acetate':
|
|
1165
|
+
# DAB=0.87*10**-5
|
|
1166
|
+
# Temp=274.2
|
|
1167
|
+
#if Diffusivity=='Air-aniline':
|
|
1168
|
+
# DAB=0.74*10**-5
|
|
1169
|
+
# Temp=299.05
|
|
1170
|
+
#if Diffusivity=='Air-chlorobenzene':
|
|
1171
|
+
# DAB=0.74*10**-5
|
|
1172
|
+
# Temp=299.05
|
|
1173
|
+
#if Diffusivity=='Air-toluene':
|
|
1174
|
+
# DAB=0.86*10**-5
|
|
1175
|
+
# Temp=299.05
|
|
1176
|
+
|
|
1177
|
+
|
|
1178
|
+
if Diffusion_Type == 'Two_way_equimolal_diffusion':
|
|
1179
|
+
NA_Two = float(DAB[Diffusivity.replace('_', '-' )] / (Gas_Constant * Temp[Diffusivity.replace('_', '-' )] * Separate_Panels_Distance)) * (Pressure_in_Panel_A - Pressure_in_Panel_B) #( [Diffusivity.replace('_', '-' )] )-->>chon khodam eshtebahan az (_) bejaye (-) estephade karadam va error dad in bakhsh ro ezafe kardam ta agar bedalil tashaboh be eshtebah az (_) estefade shod, ba (-) jayegozin kone ta moshkel bartaraf she va edame bedeh. #Air_H2O--->>'Air-H2O'
|
|
1180
|
+
C = NA_Two
|
|
1181
|
+
elif Diffusion_Type == 'one-way_diffusion':
|
|
1182
|
+
NA_One = float((DAB[Diffusivity.replace( '_', '-' )] * Total_Pressure) / (Gas_Constant * Temp[Diffusivity.replace('_', '-' )] * Separate_Panels_Distance * PressureBM)) * (Pressure_in_Panel_A - Pressure_in_Panel_B)
|
|
1183
|
+
C = NA_One
|
|
1184
|
+
|
|
1185
|
+
return C
|
|
1186
|
+
|
|
1187
|
+
|
|
1188
|
+
|
|
1189
|
+
|
|
1190
|
+
|
|
1191
|
+
|
|
1192
|
+
|
|
1193
|
+
def Defect_Density(Beta,Theta,K=0.9,Landa=1.5406):
|
|
1194
|
+
'''
|
|
1195
|
+
|
|
1196
|
+
Parameters
|
|
1197
|
+
----------
|
|
1198
|
+
Beta : Float
|
|
1199
|
+
Full width at half maximum (FWHM).
|
|
1200
|
+
Theta : Float
|
|
1201
|
+
Bragg's Diffraction Angle.
|
|
1202
|
+
K : Float, optional
|
|
1203
|
+
Scherrer Constant. The default = 0.9.
|
|
1204
|
+
Landa : Float, optional
|
|
1205
|
+
X-ray Wavelength. The default = 1.5406.
|
|
1206
|
+
|
|
1207
|
+
|
|
1208
|
+
Returns
|
|
1209
|
+
-------
|
|
1210
|
+
D : Float
|
|
1211
|
+
Crystallite size (nm)
|
|
1212
|
+
Delta : Float
|
|
1213
|
+
Density of defect for crystallite structures from XED crystallography calculated from reverse the Scherrer Equation.
|
|
1214
|
+
|
|
1215
|
+
'''
|
|
1216
|
+
Theta=math.radians(Theta)
|
|
1217
|
+
D=(K*Landa)/(Beta*math.cos(Theta))
|
|
1218
|
+
Delta=1/(D**2)
|
|
1219
|
+
return D,Delta
|
|
1220
|
+
|
|
1221
|
+
|
|
1222
|
+
|
|
1223
|
+
|
|
1224
|
+
def Diffusion_Coefficient_Calculator(Peak_Current,A,C,Scan_Rate,n,is_reversible):
|
|
1225
|
+
'''
|
|
1226
|
+
|
|
1227
|
+
|
|
1228
|
+
Parameters
|
|
1229
|
+
----------
|
|
1230
|
+
Peak_Current : Float
|
|
1231
|
+
Peak of current (A).
|
|
1232
|
+
A : Float
|
|
1233
|
+
Electrode area (cm**2).
|
|
1234
|
+
C : Float
|
|
1235
|
+
Concentration of electroactive species (mol/L).
|
|
1236
|
+
Scan_Rate : Float
|
|
1237
|
+
(mV/s)
|
|
1238
|
+
n : int
|
|
1239
|
+
number of transfered electron
|
|
1240
|
+
is_reversible: bool
|
|
1241
|
+
Type of reaction. 'True' is reversible, 'False' is irreversible
|
|
1242
|
+
|
|
1243
|
+
Returns
|
|
1244
|
+
-------
|
|
1245
|
+
Diffusion Coefficient calculates from Randles-Sevcik aquation. type:float
|
|
1246
|
+
|
|
1247
|
+
'''
|
|
1248
|
+
|
|
1249
|
+
if is_reversible.upper()=='TRUE':
|
|
1250
|
+
Diffusion_Coefficient=(Peak_Current/((2.65*10**5)*(n**(3/2))*A*C*(Scan_Rate**(1/2))))**2
|
|
1251
|
+
|
|
1252
|
+
elif is_reversible.upper()=='FALSE':
|
|
1253
|
+
Diffusion_Coefficient=(Peak_Current/(0.446*(n**(3/2))*A*C*(Scan_Rate**(1/2))))**2
|
|
1254
|
+
|
|
1255
|
+
else:
|
|
1256
|
+
raise TypeError ('Please enter a valid answer (yes or not)')
|
|
1257
|
+
|
|
1258
|
+
return(Diffusion_Coefficient)
|
|
1259
|
+
|
|
1260
|
+
|
|
1261
|
+
|
|
1262
|
+
def Distance(x,y,z,a,b,c,d):
|
|
1263
|
+
'''
|
|
1264
|
+
The formula of the distance between a point and a plane in
|
|
1265
|
+
three-dimensional space is as follows:
|
|
1266
|
+
D=(abs(a*x+b*y+c*z+d))/sqrt(a**2+b**2+c**2)
|
|
1267
|
+
|
|
1268
|
+
Parameters
|
|
1269
|
+
----------
|
|
1270
|
+
x : int
|
|
1271
|
+
The x-axis component.
|
|
1272
|
+
y : int
|
|
1273
|
+
The y-axis component.
|
|
1274
|
+
z : int
|
|
1275
|
+
The z-axis component.
|
|
1276
|
+
a : int
|
|
1277
|
+
The coefficient of x in the plane equation.
|
|
1278
|
+
b : int
|
|
1279
|
+
The coefficient of y in the plane equation.
|
|
1280
|
+
c : int
|
|
1281
|
+
The coefficient of z in the plane equation.
|
|
1282
|
+
d : int
|
|
1283
|
+
The constant in the plane equation.
|
|
1284
|
+
|
|
1285
|
+
Returns
|
|
1286
|
+
-------
|
|
1287
|
+
D : float
|
|
1288
|
+
The distance of point-to-plane
|
|
1289
|
+
|
|
1290
|
+
Example : Distnace between (1,-2,4) and the plane 13*x-6*y-5*z+3=0
|
|
1291
|
+
is 0.527
|
|
1292
|
+
|
|
1293
|
+
'''
|
|
1294
|
+
if a==b==c==0:
|
|
1295
|
+
return None
|
|
1296
|
+
else:
|
|
1297
|
+
tt=abs(a*x+b*y+c*z+d)
|
|
1298
|
+
ss=math.sqrt(a**2+b**2+c**2)
|
|
1299
|
+
D=tt/ss
|
|
1300
|
+
return D
|
|
1301
|
+
|
|
1302
|
+
|
|
1303
|
+
|
|
1304
|
+
|
|
1305
|
+
def Error_Function(z):
|
|
1306
|
+
'''
|
|
1307
|
+
|
|
1308
|
+
|
|
1309
|
+
Parameters
|
|
1310
|
+
----------
|
|
1311
|
+
z : int or float
|
|
1312
|
+
Error function argument
|
|
1313
|
+
|
|
1314
|
+
Returns
|
|
1315
|
+
-------
|
|
1316
|
+
erf : float
|
|
1317
|
+
error function value
|
|
1318
|
+
|
|
1319
|
+
'''
|
|
1320
|
+
erf=0
|
|
1321
|
+
if z<0:
|
|
1322
|
+
z=-z
|
|
1323
|
+
t=0
|
|
1324
|
+
d=0.00001
|
|
1325
|
+
while t<z:
|
|
1326
|
+
f1=math.e**(-t**2)
|
|
1327
|
+
f2=math.e**(-(t+d)**2)
|
|
1328
|
+
erf=erf+(2/(math.pi**0.5))*((f1+f2)*d/2)
|
|
1329
|
+
t=t+d
|
|
1330
|
+
|
|
1331
|
+
erf=int(erf*1000000)/1000000
|
|
1332
|
+
return erf
|
|
1333
|
+
|
|
1334
|
+
|
|
1335
|
+
|
|
1336
|
+
def Encapsulation_Efficiency(W1,W2 ):
|
|
1337
|
+
'''
|
|
1338
|
+
This function calculates the percentage of drug loaded in the carrier during drug delivery
|
|
1339
|
+
|
|
1340
|
+
Parameters
|
|
1341
|
+
----------
|
|
1342
|
+
W1 : float
|
|
1343
|
+
weight of free drug
|
|
1344
|
+
W2 : float
|
|
1345
|
+
weight of total drug
|
|
1346
|
+
|
|
1347
|
+
Returns
|
|
1348
|
+
float
|
|
1349
|
+
Encapsulation_Efficiency
|
|
1350
|
+
|
|
1351
|
+
|
|
1352
|
+
'''
|
|
1353
|
+
|
|
1354
|
+
return 1-(W1/W2)*100
|
|
1355
|
+
|
|
1356
|
+
|
|
1357
|
+
|
|
1358
|
+
|
|
1359
|
+
|
|
1360
|
+
|
|
1361
|
+
def entropy_change(heat_transfer, temperature):
|
|
1362
|
+
return heat_transfer / temperature
|
|
1363
|
+
|
|
1364
|
+
|
|
1365
|
+
|
|
1366
|
+
|
|
1367
|
+
def elastic_potential_energy(spring_constant, displacement):
|
|
1368
|
+
return 0.5 * spring_constant * displacement**2
|
|
1369
|
+
|
|
1370
|
+
|
|
1371
|
+
|
|
1372
|
+
|
|
1373
|
+
def Electrical_Resistance(v,i):
|
|
1374
|
+
'''
|
|
1375
|
+
Parameters
|
|
1376
|
+
----------
|
|
1377
|
+
This function receives the variables i, v and returns the variable R
|
|
1378
|
+
v : int
|
|
1379
|
+
Voltage or potential difference between two points
|
|
1380
|
+
i : int
|
|
1381
|
+
I is the electric current that passes through a circuit
|
|
1382
|
+
R : It represents electrical resistance.
|
|
1383
|
+
|
|
1384
|
+
Returns
|
|
1385
|
+
-------
|
|
1386
|
+
'''
|
|
1387
|
+
R =v/i
|
|
1388
|
+
return R
|
|
1389
|
+
|
|
1390
|
+
|
|
1391
|
+
|
|
1392
|
+
|
|
1393
|
+
|
|
1394
|
+
def Euler_Diff_Solver(a , b, xf , h , x0 =0 ,y0 =0 ):
|
|
1395
|
+
'''
|
|
1396
|
+
This function solve linear differential equation of the following form:
|
|
1397
|
+
yprim = dy/dx = f(x,y) = a*x^2 + b*x
|
|
1398
|
+
by the Euler's method that is a numerical method for
|
|
1399
|
+
approximating differential equations.
|
|
1400
|
+
|
|
1401
|
+
Parameters
|
|
1402
|
+
----------
|
|
1403
|
+
a : float
|
|
1404
|
+
Polynomial coefficient..
|
|
1405
|
+
b : float
|
|
1406
|
+
Polynomial coefficient.
|
|
1407
|
+
xf : float
|
|
1408
|
+
Independent variable's final value.
|
|
1409
|
+
h : float
|
|
1410
|
+
Step size.
|
|
1411
|
+
x0 : float, optional
|
|
1412
|
+
Independent variable's initial value. The default is 0.
|
|
1413
|
+
y0 : float, optional
|
|
1414
|
+
Initial function value at x0 (y0 = y(x0)). The default is 0.
|
|
1415
|
+
|
|
1416
|
+
Raises
|
|
1417
|
+
------
|
|
1418
|
+
TypeError
|
|
1419
|
+
The quadratic coefficient of the equation should not be zero.
|
|
1420
|
+
|
|
1421
|
+
Returns
|
|
1422
|
+
-------
|
|
1423
|
+
y : float
|
|
1424
|
+
Returns function value at desired point (xf) or y(xf).
|
|
1425
|
+
|
|
1426
|
+
'''
|
|
1427
|
+
|
|
1428
|
+
if a == 0:
|
|
1429
|
+
raise TypeError('The coefficient a should not be zero')
|
|
1430
|
+
return
|
|
1431
|
+
varL = xf - x0
|
|
1432
|
+
varLL = int(varL/h)
|
|
1433
|
+
for i in range(varLL):
|
|
1434
|
+
y = Euler_Method(a,b,x0,y0,h)
|
|
1435
|
+
y0 = y
|
|
1436
|
+
x0 = x0 +h
|
|
1437
|
+
return y
|
|
1438
|
+
|
|
1439
|
+
|
|
1440
|
+
|
|
1441
|
+
|
|
1442
|
+
|
|
1443
|
+
def Euler_Method(a,b, h, x0,y0):
|
|
1444
|
+
|
|
1445
|
+
'''
|
|
1446
|
+
Euler's method law: y = y0 + h *yprim
|
|
1447
|
+
|
|
1448
|
+
Parameters
|
|
1449
|
+
----------
|
|
1450
|
+
a : float
|
|
1451
|
+
Polynomial coefficient.
|
|
1452
|
+
b : float
|
|
1453
|
+
polynomial coefficient.
|
|
1454
|
+
x0 : float
|
|
1455
|
+
Initial value.
|
|
1456
|
+
y0 = y(x0) : float
|
|
1457
|
+
function value.
|
|
1458
|
+
h : float
|
|
1459
|
+
Step size.
|
|
1460
|
+
|
|
1461
|
+
Returns
|
|
1462
|
+
-------
|
|
1463
|
+
This function returns function value (y) at specific value (x).
|
|
1464
|
+
|
|
1465
|
+
'''
|
|
1466
|
+
var1 = x0;
|
|
1467
|
+
yprim = a*(var1**2)+b*var1;
|
|
1468
|
+
y = y0 + h *yprim # Euler's method
|
|
1469
|
+
return y
|
|
1470
|
+
|
|
1471
|
+
|
|
1472
|
+
|
|
1473
|
+
|
|
1474
|
+
|
|
1475
|
+
|
|
1476
|
+
|
|
1477
|
+
|
|
1478
|
+
def First_Row_Pascal_Triangle(k):
|
|
1479
|
+
|
|
1480
|
+
result=1
|
|
1481
|
+
|
|
1482
|
+
for i in range(1,k+1):
|
|
1483
|
+
result*=i
|
|
1484
|
+
|
|
1485
|
+
return result
|
|
1486
|
+
|
|
1487
|
+
|
|
1488
|
+
|
|
1489
|
+
|
|
1490
|
+
|
|
1491
|
+
|
|
1492
|
+
def Fibonachi_Sequence (N):
|
|
1493
|
+
fibo = [0,1]
|
|
1494
|
+
first = 0
|
|
1495
|
+
second = 1
|
|
1496
|
+
for i in range(2,N):
|
|
1497
|
+
new = first + second
|
|
1498
|
+
fibo.append(new)
|
|
1499
|
+
first = second
|
|
1500
|
+
second = new
|
|
1501
|
+
return fibo
|
|
1502
|
+
|
|
1503
|
+
|
|
1504
|
+
|
|
1505
|
+
|
|
1506
|
+
def Factorial(a):
|
|
1507
|
+
'''
|
|
1508
|
+
The product of all positive integers less than or equal to a given positive integer.
|
|
1509
|
+
|
|
1510
|
+
Parameters
|
|
1511
|
+
----------
|
|
1512
|
+
a : int
|
|
1513
|
+
|
|
1514
|
+
|
|
1515
|
+
Returns
|
|
1516
|
+
-------
|
|
1517
|
+
factorial: int
|
|
1518
|
+
the product of all positive integers less than or equal to a given positive integer .
|
|
1519
|
+
|
|
1520
|
+
'''
|
|
1521
|
+
if a==0:
|
|
1522
|
+
return 1
|
|
1523
|
+
else:
|
|
1524
|
+
i=1
|
|
1525
|
+
factorial=a
|
|
1526
|
+
while a!=i:
|
|
1527
|
+
factorial=factorial*(a-i)
|
|
1528
|
+
i=i+1
|
|
1529
|
+
return factorial
|
|
1530
|
+
|
|
1531
|
+
|
|
1532
|
+
|
|
1533
|
+
|
|
1534
|
+
|
|
1535
|
+
def Fabric_GSM(Warp,Weft,Warp_Count_Nm,Weft_Count_Nm,Shrinkage_Percent=5):
|
|
1536
|
+
'''
|
|
1537
|
+
This function calculates weight fabric in GSM unit.
|
|
1538
|
+
|
|
1539
|
+
Parameters
|
|
1540
|
+
----------
|
|
1541
|
+
Warp : int or float
|
|
1542
|
+
The number of warps in 1 cm.
|
|
1543
|
+
Weft : int or float
|
|
1544
|
+
The number of wefts in 1 cm.
|
|
1545
|
+
Warp_Count_Nm : int or float
|
|
1546
|
+
Warp yarn metric count.
|
|
1547
|
+
Weft_Count_Nm : int or float
|
|
1548
|
+
Weft yarn metric count.
|
|
1549
|
+
Shrinkage_Percent : int or float, optional
|
|
1550
|
+
The percentage difference in the length of woven and non-woven yarn. The default is 5.
|
|
1551
|
+
Fabric_GSM : int or float
|
|
1552
|
+
Result.
|
|
1553
|
+
|
|
1554
|
+
'''
|
|
1555
|
+
Fabric_weight= ((Warp*100)/Warp_Count_Nm )+ ((Weft*100)/Weft_Count_Nm )
|
|
1556
|
+
Fabric_GSM= Fabric_weight * (1+(Shrinkage_Percent/100))
|
|
1557
|
+
return Fabric_GSM
|
|
1558
|
+
|
|
1559
|
+
|
|
1560
|
+
|
|
1561
|
+
|
|
1562
|
+
def Fabric_Drape_Coefficient(fabric_weight,fabric_thickness,bending_length):
|
|
1563
|
+
'''
|
|
1564
|
+
This function estimates the drape coefficient of fabric according to 3 factors:
|
|
1565
|
+
|
|
1566
|
+
Parameters
|
|
1567
|
+
----------
|
|
1568
|
+
fabric_weight : int or float
|
|
1569
|
+
weight of fabric.
|
|
1570
|
+
fabric_thickness : int or float
|
|
1571
|
+
thickness of fabric.
|
|
1572
|
+
bending_length : int or float
|
|
1573
|
+
the length difference.
|
|
1574
|
+
Drape_Coefficient : int or float
|
|
1575
|
+
Result.
|
|
1576
|
+
|
|
1577
|
+
'''
|
|
1578
|
+
Drape_Coefficient = (fabric_weight*bending_length)/(fabric_thickness**2)
|
|
1579
|
+
return Drape_Coefficient
|
|
1580
|
+
|
|
1581
|
+
|
|
1582
|
+
|
|
1583
|
+
|
|
1584
|
+
|
|
1585
|
+
def Fabric_Porosity(air_volume,total_volume):
|
|
1586
|
+
'''
|
|
1587
|
+
|
|
1588
|
+
|
|
1589
|
+
Parameters
|
|
1590
|
+
----------
|
|
1591
|
+
air_volume : int
|
|
1592
|
+
enter the volume of pores in fabric in mm^3.
|
|
1593
|
+
total_volume : int
|
|
1594
|
+
Enter the total volume of fabric in mm^3.
|
|
1595
|
+
Returns
|
|
1596
|
+
-------
|
|
1597
|
+
Fabric_porosity : int
|
|
1598
|
+
This function calculates the fabric porosity in mm^3.
|
|
1599
|
+
|
|
1600
|
+
'''
|
|
1601
|
+
FP=total_volume-air_volume
|
|
1602
|
+
return FP
|
|
1603
|
+
|
|
1604
|
+
|
|
1605
|
+
|
|
1606
|
+
|
|
1607
|
+
|
|
1608
|
+
def Fabric_weight(density,area):
|
|
1609
|
+
'''
|
|
1610
|
+
|
|
1611
|
+
|
|
1612
|
+
Parameters
|
|
1613
|
+
----------
|
|
1614
|
+
density : int
|
|
1615
|
+
enter the density of fabric in g/mm^2.
|
|
1616
|
+
area : int
|
|
1617
|
+
Enter the area of fabric in mm^2.
|
|
1618
|
+
Returns
|
|
1619
|
+
-------
|
|
1620
|
+
Fabric_weight : int
|
|
1621
|
+
This function calculates the fabric weight in g.
|
|
1622
|
+
|
|
1623
|
+
'''
|
|
1624
|
+
FW=density*area
|
|
1625
|
+
return FW
|
|
1626
|
+
|
|
1627
|
+
|
|
1628
|
+
|
|
1629
|
+
|
|
1630
|
+
|
|
1631
|
+
|
|
1632
|
+
|
|
1633
|
+
def faradays_law(induced_emf, time, magnetic_flux):
|
|
1634
|
+
return induced_emf - time * magnetic_flux
|
|
1635
|
+
|
|
1636
|
+
|
|
1637
|
+
|
|
1638
|
+
|
|
1639
|
+
|
|
1640
|
+
def Filler_Weight(M,FR1,FR2,FR3):#M=polymer matrix weight in gr & F1=first flame retardant weight in gr & F2=second flame retardant weight in gr & F3=third flame retardant weight in gr
|
|
1641
|
+
a=[FR1/(FR1+FR2+FR3+M)]#FR1 weight%
|
|
1642
|
+
b=[FR2/(FR1+FR2+FR3+M)]#FR2 weight %
|
|
1643
|
+
c=[FR3/(FR1+FR2+FR3+M)]#FR3 weight %
|
|
1644
|
+
return a,b,c
|
|
1645
|
+
|
|
1646
|
+
|
|
1647
|
+
|
|
1648
|
+
|
|
1649
|
+
|
|
1650
|
+
def Fick_Sec_Thin(Thickness,Diffusion_coefficient,Time,Thin_layer_Consistency,Position,Thin_Layer_Metal,Second_metal):
|
|
1651
|
+
'''
|
|
1652
|
+
Fick's second law predicts how diffusion causes the concentration to change with respect to time.
|
|
1653
|
+
In the case where a thin film of a different metal is placed between two thick films of another metal,
|
|
1654
|
+
and due to heat and a certain time, the amount of penetration of the first metal into the second metal will be investigated.
|
|
1655
|
+
Parameters
|
|
1656
|
+
----------
|
|
1657
|
+
Thickness : float
|
|
1658
|
+
The thickness of the thin layer metal is used. use cm for input
|
|
1659
|
+
Diffusion_coefficient : float
|
|
1660
|
+
It shows the diffusion coefficient of the metal placed in the middle compared to the metal on its side. use cm^2/seconds for input
|
|
1661
|
+
Time : float
|
|
1662
|
+
It shows the duration of the diffusion check. use seconds for input
|
|
1663
|
+
Thin_layer_Consistency : float
|
|
1664
|
+
It shows the initial concentration of thin metal. use gr/cm^3 for input
|
|
1665
|
+
Position : float
|
|
1666
|
+
Indicates the location required to check the concentration. use cm for input
|
|
1667
|
+
Thin_Layer_Metal : str
|
|
1668
|
+
What is the material of the thin layer used?
|
|
1669
|
+
Second_metal : str
|
|
1670
|
+
What is the metal material in which the primary metal should penetrate?.
|
|
1671
|
+
|
|
1672
|
+
Returns
|
|
1673
|
+
-------
|
|
1674
|
+
C_x_t : float
|
|
1675
|
+
It shows the concentration of the metal separated from the thin layer and moved in a certain time in the desired location. output will be gr/cm^3
|
|
1676
|
+
'''
|
|
1677
|
+
pi=3.14
|
|
1678
|
+
if Thin_Layer_Metal=='Cu'and Second_metal=='Ni':
|
|
1679
|
+
Diffusion_coefficient=0.2698 # @Temprature=1000 K
|
|
1680
|
+
if Thin_Layer_Metal=='Cr'and Second_metal=='Ni':
|
|
1681
|
+
Diffusion_coefficient=0.0299 # @Temprature=1000 K
|
|
1682
|
+
C_x_t=((Thickness*Thin_layer_Consistency)/(2*(pi*Diffusion_coefficient*Time)**(0.5)))*math.exp((-(Position)**2)/(4*Diffusion_coefficient*Time))
|
|
1683
|
+
return C_x_t
|
|
1684
|
+
|
|
1685
|
+
|
|
1686
|
+
|
|
1687
|
+
|
|
1688
|
+
|
|
1689
|
+
def Final_Temp_Irreversible_Adiabatic(Initial_temperature,External_pressure,Internal_pressure,C_V,C_P,R,Unit_of_measurement,Number_of_gas_atoms):
|
|
1690
|
+
'''
|
|
1691
|
+
Parameters
|
|
1692
|
+
----------
|
|
1693
|
+
Initial_temperature : float
|
|
1694
|
+
Initial temperature of an ideal gas.
|
|
1695
|
+
External_pressure : float
|
|
1696
|
+
The pressure that enters the system from the environment.
|
|
1697
|
+
Internal_pressure : float
|
|
1698
|
+
The pressure that enters the system wall from the inside.
|
|
1699
|
+
C_V : float
|
|
1700
|
+
The ideal gas constant-pressure specific heat.
|
|
1701
|
+
C_P : float
|
|
1702
|
+
The ideal gas constant-pressure specific heat..
|
|
1703
|
+
R : float
|
|
1704
|
+
The molar gas constant or ideal gas constant.
|
|
1705
|
+
Unit_of_measurement : str
|
|
1706
|
+
DESCRIPTION.
|
|
1707
|
+
Number_of_gas_atoms : str
|
|
1708
|
+
DESCRIPTION.
|
|
1709
|
+
|
|
1710
|
+
Returns
|
|
1711
|
+
-------
|
|
1712
|
+
Final_Temp : float
|
|
1713
|
+
Outputs the final temperature if the system operates adiabatically irreversible.
|
|
1714
|
+
'''
|
|
1715
|
+
if Unit_of_measurement=='Jouls':
|
|
1716
|
+
R=8.314
|
|
1717
|
+
if Number_of_gas_atoms=='one':
|
|
1718
|
+
C_V=1.5*R
|
|
1719
|
+
C_P=2.5*R
|
|
1720
|
+
if Number_of_gas_atoms=='two':
|
|
1721
|
+
C_V=2.5*R
|
|
1722
|
+
C_P=3.5*R
|
|
1723
|
+
if Number_of_gas_atoms=='multi':
|
|
1724
|
+
C_V=3.5*R
|
|
1725
|
+
C_P=4.5*R
|
|
1726
|
+
elif Unit_of_measurement=='Calories':
|
|
1727
|
+
R=1.98
|
|
1728
|
+
if Number_of_gas_atoms=='one':
|
|
1729
|
+
C_V=1.5*R
|
|
1730
|
+
C_P=2.5*R
|
|
1731
|
+
if Number_of_gas_atoms=='two':
|
|
1732
|
+
C_V=2.5*R
|
|
1733
|
+
C_P=3.5*R
|
|
1734
|
+
if Number_of_gas_atoms=='multi':
|
|
1735
|
+
C_V=3.5*R
|
|
1736
|
+
C_P=4.5*R
|
|
1737
|
+
Final_Temp=Initial_temperature*((C_V+(External_pressure/Internal_pressure)*R)/C_P)
|
|
1738
|
+
return Final_Temp
|
|
1739
|
+
|
|
1740
|
+
|
|
1741
|
+
|
|
1742
|
+
|
|
1743
|
+
|
|
1744
|
+
def Fracture_Toughness(s, c, location):
|
|
1745
|
+
|
|
1746
|
+
'''
|
|
1747
|
+
this function calculates fracture toughness
|
|
1748
|
+
based on applied stress, crack length, and location
|
|
1749
|
+
|
|
1750
|
+
fracture toghness formula:
|
|
1751
|
+
K1C = a*s* (math.sqrt(3.14* c))
|
|
1752
|
+
|
|
1753
|
+
where:
|
|
1754
|
+
|
|
1755
|
+
K1C is the fracture toughness,
|
|
1756
|
+
a is a geometric factor,
|
|
1757
|
+
s is the applied stress,
|
|
1758
|
+
c is the crack length.
|
|
1759
|
+
|
|
1760
|
+
|
|
1761
|
+
Parameters
|
|
1762
|
+
-----------
|
|
1763
|
+
1. s: int ---> (MPa)
|
|
1764
|
+
applied stress
|
|
1765
|
+
|
|
1766
|
+
2. c: float ---> (m)
|
|
1767
|
+
crack length
|
|
1768
|
+
|
|
1769
|
+
3. location: str
|
|
1770
|
+
represents the location of crack
|
|
1771
|
+
|
|
1772
|
+
Returns --> K1C (fracture toughness)
|
|
1773
|
+
|
|
1774
|
+
'''
|
|
1775
|
+
|
|
1776
|
+
if location == 'surface' or 'side':
|
|
1777
|
+
a = 1.12
|
|
1778
|
+
K1C = a*s* (math.sqrt(3.14* c))
|
|
1779
|
+
|
|
1780
|
+
elif location == 'centeral':
|
|
1781
|
+
a = 1
|
|
1782
|
+
c = c/2
|
|
1783
|
+
K1C = a*s* (math.sqrt(3.14* c))
|
|
1784
|
+
|
|
1785
|
+
|
|
1786
|
+
return K1C
|
|
1787
|
+
|
|
1788
|
+
|
|
1789
|
+
|
|
1790
|
+
|
|
1791
|
+
def Faraday_Corrosion(current_density, time, atomic_weight, density, valence):
|
|
1792
|
+
"""
|
|
1793
|
+
calculate penetration depth from corrosion
|
|
1794
|
+
current_density: A/m²
|
|
1795
|
+
time:hour
|
|
1796
|
+
atomic_weight: g/mol
|
|
1797
|
+
density: g/cm³
|
|
1798
|
+
valence
|
|
1799
|
+
"""
|
|
1800
|
+
K = 3.27e-4 #μm/(A/m²·h)
|
|
1801
|
+
faraday=(K * current_density * time * atomic_weight / (density * valence))
|
|
1802
|
+
return faraday
|
|
1803
|
+
|
|
1804
|
+
|
|
1805
|
+
|
|
1806
|
+
|
|
1807
|
+
|
|
1808
|
+
def Friction_Law(mass,angle,/,MOTCS,moving):
|
|
1809
|
+
'''
|
|
1810
|
+
This function calculates the friction force on the object by taking the mass of the desired object, the material of the two contact surfaces, the angle of the contact surface with the horizon and the movement state of the object.
|
|
1811
|
+
|
|
1812
|
+
Parameters
|
|
1813
|
+
----------
|
|
1814
|
+
mass : int
|
|
1815
|
+
The mass of the desired object (KG).
|
|
1816
|
+
angle : int
|
|
1817
|
+
The angle of the contact surface with respect to the horizon (RAD).
|
|
1818
|
+
MOTCS : str
|
|
1819
|
+
Material of two contact surfaces.
|
|
1820
|
+
The contact surfaces considered :
|
|
1821
|
+
STEEL ON STEEL
|
|
1822
|
+
STEEL ON ALUMINUM
|
|
1823
|
+
STEEL ON COPPER
|
|
1824
|
+
COPPER ON CAST IRON
|
|
1825
|
+
COPPER ON GLASS
|
|
1826
|
+
GLASS ON GLASS
|
|
1827
|
+
RUBBER ON DRY CONCRETE
|
|
1828
|
+
RUBBER ON WET CONCRETE
|
|
1829
|
+
TEFLON ON TEFLON
|
|
1830
|
+
moving : str
|
|
1831
|
+
Is the desired object moving? (YES OR NO).
|
|
1832
|
+
|
|
1833
|
+
Returns
|
|
1834
|
+
-------
|
|
1835
|
+
F : float
|
|
1836
|
+
Frictional force applied to the target object (N).
|
|
1837
|
+
|
|
1838
|
+
'''
|
|
1839
|
+
global F
|
|
1840
|
+
m=moving.upper()
|
|
1841
|
+
M=MOTCS.upper()
|
|
1842
|
+
if m=='YES':
|
|
1843
|
+
if M=='STEEL ON STEEL':
|
|
1844
|
+
F=mass*9.81*math.cos(angle)*0.57
|
|
1845
|
+
if M=='STEEL ON ALUMINUM':
|
|
1846
|
+
F=mass*9.81*math.cos(angle)*0.47
|
|
1847
|
+
if M=='STEEL ON COPPER':
|
|
1848
|
+
F=mass*9.81*math.cos(angle)*0.36
|
|
1849
|
+
if M=='COPPER ON CAST IRON':
|
|
1850
|
+
F=mass*9.81*math.cos(angle)*0.29
|
|
1851
|
+
if M=='COPPER ON GLASS':
|
|
1852
|
+
F=mass*9.81*math.cos(angle)*0.53
|
|
1853
|
+
if M=='GLASS ON GLASS':
|
|
1854
|
+
F=mass*9.81*math.cos(angle)*0.40
|
|
1855
|
+
if M=='RUBBER ON DRY CONCRETE':
|
|
1856
|
+
F=mass*9.81*math.cos(angle)*0.8
|
|
1857
|
+
if M=='RUBBER ON WET CONCRETE':
|
|
1858
|
+
F=mass*9.81*math.cos(angle)*0.25
|
|
1859
|
+
if M=='TEFLON ON TEFLON':
|
|
1860
|
+
F=mass*9.81*math.cos(angle)*0.04
|
|
1861
|
+
return F
|
|
1862
|
+
if m=='NO':
|
|
1863
|
+
if M=='STEEL ON STEEL':
|
|
1864
|
+
F=mass*9.81*math.cos(angle)*0.74
|
|
1865
|
+
if M=='STEEL ON ALUMINUM':
|
|
1866
|
+
F=mass*9.81*math.cos(angle)*0.61
|
|
1867
|
+
if M=='STEEL ON COPPER':
|
|
1868
|
+
F=mass*9.81*math.cos(angle)*0.53
|
|
1869
|
+
if M=='COPPER ON CAST IRON':
|
|
1870
|
+
F=mass*9.81*math.cos(angle)*1.05
|
|
1871
|
+
if M=='COPPER ON GLASS':
|
|
1872
|
+
F=mass*9.81*math.cos(angle)*0.68
|
|
1873
|
+
if M=='GLASS ON GLASS':
|
|
1874
|
+
F=mass*9.81*math.cos(angle)*0.94
|
|
1875
|
+
if M=='RUBBER ON DRY CONCRETE':
|
|
1876
|
+
F=mass*9.81*math.cos(angle)*1
|
|
1877
|
+
if M=='RUBBER ON WET CONCRETE':
|
|
1878
|
+
F=mass*9.81*math.cos(angle)*0.3
|
|
1879
|
+
if M=='TEFLON ON TEFLON':
|
|
1880
|
+
F=mass*9.81*math.cos(angle)*0.04
|
|
1881
|
+
return F
|
|
1882
|
+
|
|
1883
|
+
|
|
1884
|
+
|
|
1885
|
+
|
|
1886
|
+
|
|
1887
|
+
|
|
1888
|
+
|
|
1889
|
+
def Geometric_Sequence(first_variable,second_variable):
|
|
1890
|
+
'''
|
|
1891
|
+
This function obtains the result of a geometric progression
|
|
1892
|
+
|
|
1893
|
+
Parameters
|
|
1894
|
+
----------
|
|
1895
|
+
first_variable : int
|
|
1896
|
+
The value of the first variable.
|
|
1897
|
+
second_variable : int
|
|
1898
|
+
The value of the second variable.
|
|
1899
|
+
|
|
1900
|
+
Returns
|
|
1901
|
+
-------
|
|
1902
|
+
int
|
|
1903
|
+
gives the result of the geometric exponential function.
|
|
1904
|
+
|
|
1905
|
+
'''
|
|
1906
|
+
if second_variable>1:
|
|
1907
|
+
m=(first_variable*(Geometric_Sequence(first_variable,second_variable-1)))/2
|
|
1908
|
+
|
|
1909
|
+
else:
|
|
1910
|
+
|
|
1911
|
+
return 1
|
|
1912
|
+
return m
|
|
1913
|
+
|
|
1914
|
+
|
|
1915
|
+
|
|
1916
|
+
|
|
1917
|
+
def gauss_law(electric_field, surface_area, electric_flux):
|
|
1918
|
+
return electric_field * surface_area - electric_flux
|
|
1919
|
+
|
|
1920
|
+
|
|
1921
|
+
|
|
1922
|
+
|
|
1923
|
+
def Gibs_free_energy(H0,T,S0):
|
|
1924
|
+
'''
|
|
1925
|
+
Parameters
|
|
1926
|
+
----------
|
|
1927
|
+
H0 : float
|
|
1928
|
+
Enthalpy of material in the pressure of 1atm in pure state. The number should be in terms of joul or kilojoul. It must have the same unit as entropy.
|
|
1929
|
+
T : float
|
|
1930
|
+
Temperature of material. The temperature should be in terms of Kelvin.
|
|
1931
|
+
S0 : float
|
|
1932
|
+
Entropy of material. The number should be in terms of joul or kilojoul. It must have the same unit as enthalpy.
|
|
1933
|
+
|
|
1934
|
+
Returns
|
|
1935
|
+
-------
|
|
1936
|
+
G : float
|
|
1937
|
+
This function give us the amount of Gibs free energy of the material at the pressure of 1atm. The terms of this function is joul or kilojoul.
|
|
1938
|
+
|
|
1939
|
+
'''
|
|
1940
|
+
G0=H0-T*S0
|
|
1941
|
+
return G0
|
|
1942
|
+
|
|
1943
|
+
|
|
1944
|
+
|
|
1945
|
+
|
|
1946
|
+
|
|
1947
|
+
def Gravitational_force(G,FT):
|
|
1948
|
+
'''
|
|
1949
|
+
Parameters
|
|
1950
|
+
----------
|
|
1951
|
+
G : float
|
|
1952
|
+
The gravitational force is a force that attracts any two objects with mass.
|
|
1953
|
+
FT : float
|
|
1954
|
+
The force of gravity varies with latitude and increases from about 9.780 m/s2 at the Equator to about 9.832 m/s2 at the poles.
|
|
1955
|
+
|
|
1956
|
+
Returns
|
|
1957
|
+
-------
|
|
1958
|
+
F : float
|
|
1959
|
+
The force of gravity is also called as Newton's law of gravitation. Mathematically, F = GMmr2.
|
|
1960
|
+
where F = force of gravity, G = gravitational constant, M = mass of one object, m = mass of other object, r = distance between two objects.
|
|
1961
|
+
|
|
1962
|
+
'''
|
|
1963
|
+
if FT=='Force of gravity total':
|
|
1964
|
+
F=G*((5.972*(10**24)*1.989*(10**30))/((1.496*(10**11))**2))
|
|
1965
|
+
return F
|
|
1966
|
+
|
|
1967
|
+
|
|
1968
|
+
|
|
1969
|
+
|
|
1970
|
+
def Gravitational_force_formula(g,m_mars,m_sun,r_mars_sun):
|
|
1971
|
+
'''
|
|
1972
|
+
|
|
1973
|
+
|
|
1974
|
+
Parameters
|
|
1975
|
+
----------
|
|
1976
|
+
g : float
|
|
1977
|
+
The gravitational force is a force that attracts any two objects with mass.
|
|
1978
|
+
m_mars : float
|
|
1979
|
+
Mars' mass is 6.42 x 1023 kilograms, about 10 times less than Earth.
|
|
1980
|
+
This affects the force of gravity. Gravity on Mars is 38 percent of Earth's gravity,
|
|
1981
|
+
so a 100-pound person on Earth would weigh 38 pounds on Mars
|
|
1982
|
+
m_sun : float
|
|
1983
|
+
The sun has a mass of 1.9891x1030 kg = 4.384x1030 lb = 2.192x1027 tons, or a mass 333,000 times that of the Earth.
|
|
1984
|
+
The radius of the Sun is 696,265,000 meters = 696,265 km = 432,639 mi or a radius 109 times that of the Earth.
|
|
1985
|
+
r_mars_sun : float
|
|
1986
|
+
Mars is about 128 million miles (206 million km) from the sun,
|
|
1987
|
+
and at its farthest distance (aphelion) Mars is about 154 million miles (249 million km) from the sun.
|
|
1988
|
+
|
|
1989
|
+
Returns
|
|
1990
|
+
-------
|
|
1991
|
+
F2 : float
|
|
1992
|
+
The force of gravity is also called as Newton's law of gravitation.
|
|
1993
|
+
Mathematically, F = GMmr2.
|
|
1994
|
+
where F = force of gravity, G = gravitational constant, M = mass of one object, m = mass of other object, r = distance between two objects.
|
|
1995
|
+
|
|
1996
|
+
'''
|
|
1997
|
+
if g=='gravity':
|
|
1998
|
+
F2=g*((m_mars*m_sun)/r_mars_sun**2)
|
|
1999
|
+
return F2
|
|
2000
|
+
|
|
2001
|
+
|
|
2002
|
+
|
|
2003
|
+
|
|
2004
|
+
|
|
2005
|
+
|
|
2006
|
+
def Heat_Transfer_Rate (Thermal_conductivity,area, tempreture_difference):
|
|
2007
|
+
'''
|
|
2008
|
+
This function is used to calculate heat transfer rate by using thermal conductivity, area of transformation, and tempreture of to sides of transformation.
|
|
2009
|
+
In this formula, heat transfer rate is in Btu/(hr*square ft*F), area is in square ft, and tempreture difference is in F.
|
|
2010
|
+
|
|
2011
|
+
'''
|
|
2012
|
+
Heat_Transfer_Rate=Thermal_conductivity*area*tempreture_difference
|
|
2013
|
+
return Heat_Transfer_Rate
|
|
2014
|
+
|
|
2015
|
+
|
|
2016
|
+
|
|
2017
|
+
|
|
2018
|
+
|
|
2019
|
+
def Half_Inhibitory_Concentration(A1,A2,A3):
|
|
2020
|
+
'''
|
|
2021
|
+
This function determines the drug’s efficacy in biological process inhibition
|
|
2022
|
+
|
|
2023
|
+
Parameters
|
|
2024
|
+
----------
|
|
2025
|
+
A1 : int
|
|
2026
|
+
absorbance of the experimental wells
|
|
2027
|
+
A2 : int
|
|
2028
|
+
absorbance of the control wells
|
|
2029
|
+
A3 : int
|
|
2030
|
+
absorbance of the blank wells
|
|
2031
|
+
|
|
2032
|
+
Returns
|
|
2033
|
+
float
|
|
2034
|
+
Half _Inhibitory_Concentration
|
|
2035
|
+
|
|
2036
|
+
'''
|
|
2037
|
+
return 1-(A1-A3/A2-A3)*100
|
|
2038
|
+
|
|
2039
|
+
|
|
2040
|
+
|
|
2041
|
+
|
|
2042
|
+
|
|
2043
|
+
def Hall_Petch(d_grain, sigma0, k):
|
|
2044
|
+
"""
|
|
2045
|
+
calculate yield strengh with grain size in Hall Petch
|
|
2046
|
+
k(float) = MPa·√m Hall Petch constant
|
|
2047
|
+
d_grain = size of grain according to meter
|
|
2048
|
+
"""
|
|
2049
|
+
hall=(sigma0 + k / (d_grain**0.5))
|
|
2050
|
+
return hall
|
|
2051
|
+
|
|
2052
|
+
|
|
2053
|
+
|
|
2054
|
+
|
|
2055
|
+
|
|
2056
|
+
def Hall_petch(frictional_stress,k,grain_diameter):
|
|
2057
|
+
"""
|
|
2058
|
+
|
|
2059
|
+
|
|
2060
|
+
Parameters
|
|
2061
|
+
----------
|
|
2062
|
+
frictional_stress : float
|
|
2063
|
+
Sigma0 which refers to resistance of lattice to dislocation movement.
|
|
2064
|
+
k : float
|
|
2065
|
+
grain boundry locking term.
|
|
2066
|
+
grain_diameter : float
|
|
2067
|
+
average diameter of grains
|
|
2068
|
+
|
|
2069
|
+
Returns
|
|
2070
|
+
-------
|
|
2071
|
+
Yield stress (in MPa)
|
|
2072
|
+
|
|
2073
|
+
"""
|
|
2074
|
+
yield_stress=frictional_stress+k/(grain_diameter)**0.5
|
|
2075
|
+
return yield_stress
|
|
2076
|
+
|
|
2077
|
+
|
|
2078
|
+
|
|
2079
|
+
|
|
2080
|
+
|
|
2081
|
+
def Hooke(strain,young_modulus):
|
|
2082
|
+
stress=young_modulus*strain
|
|
2083
|
+
return stress
|
|
2084
|
+
|
|
2085
|
+
|
|
2086
|
+
|
|
2087
|
+
def heat_transfer(thermal_conductivity, area, temperature_difference, thickness):
|
|
2088
|
+
return thermal_conductivity * area * temperature_difference / thickness
|
|
2089
|
+
|
|
2090
|
+
|
|
2091
|
+
|
|
2092
|
+
|
|
2093
|
+
def hookes_law(spring_constant, displacement):
|
|
2094
|
+
return spring_constant * displacement
|
|
2095
|
+
|
|
2096
|
+
|
|
2097
|
+
|
|
2098
|
+
|
|
2099
|
+
def hadamard_product(matrix1, matrix2):
|
|
2100
|
+
return np.multiply(matrix1, matrix2)
|
|
2101
|
+
|
|
2102
|
+
|
|
2103
|
+
|
|
2104
|
+
|
|
2105
|
+
|
|
2106
|
+
def Heat_Capacity (m,c,T1,T2):
|
|
2107
|
+
'''
|
|
2108
|
+
This function caclulate the amount of heat capacity of a mass
|
|
2109
|
+
Parameters
|
|
2110
|
+
----------
|
|
2111
|
+
m : Float
|
|
2112
|
+
mass.
|
|
2113
|
+
c : float
|
|
2114
|
+
specific heat coefficient.
|
|
2115
|
+
T1 : float
|
|
2116
|
+
primary temperature.
|
|
2117
|
+
T2 : float
|
|
2118
|
+
secondary temperature.
|
|
2119
|
+
|
|
2120
|
+
'''
|
|
2121
|
+
Q=m*c*(T2-T1)
|
|
2122
|
+
if Q<0:
|
|
2123
|
+
str='The mentioned material has lost heat'
|
|
2124
|
+
if Q==0:
|
|
2125
|
+
str='The mentioned material,s heat has not changed'
|
|
2126
|
+
if Q>0:
|
|
2127
|
+
str='The mentioned material has gained heat'
|
|
2128
|
+
return Q,str
|
|
2129
|
+
|
|
2130
|
+
|
|
2131
|
+
|
|
2132
|
+
|
|
2133
|
+
|
|
2134
|
+
def HeatـTransferـCoefficient(k,A,t1,t2,d):
|
|
2135
|
+
'''
|
|
2136
|
+
|
|
2137
|
+
|
|
2138
|
+
Parameters
|
|
2139
|
+
----------
|
|
2140
|
+
This function receives the variables k, A, t1,t2,d and returns the variable Q
|
|
2141
|
+
Q : int
|
|
2142
|
+
It indicates the rate of heat transfer.
|
|
2143
|
+
k : int
|
|
2144
|
+
Heat transfer coefficient
|
|
2145
|
+
A : int
|
|
2146
|
+
is the heat transfer coefficient.
|
|
2147
|
+
t1 : int
|
|
2148
|
+
The area of the surface from which heat is transferred.
|
|
2149
|
+
t2 : int
|
|
2150
|
+
Initial temperature
|
|
2151
|
+
d : int
|
|
2152
|
+
Secondary temperature
|
|
2153
|
+
|
|
2154
|
+
'''
|
|
2155
|
+
Q=k*A*(t2-t1/d)
|
|
2156
|
+
return Q
|
|
2157
|
+
|
|
2158
|
+
|
|
2159
|
+
|
|
2160
|
+
|
|
2161
|
+
def Hardness_vickers(F,d):
|
|
2162
|
+
'''
|
|
2163
|
+
Parameters
|
|
2164
|
+
----------
|
|
2165
|
+
F : float
|
|
2166
|
+
Applied force in terms of kilogram.
|
|
2167
|
+
d : float
|
|
2168
|
+
Medium diameter of indentor effect in terms of milimeter.
|
|
2169
|
+
|
|
2170
|
+
Returns
|
|
2171
|
+
-------
|
|
2172
|
+
HV : Vickers hardness
|
|
2173
|
+
This function give us the amount of hardness of material that evaluated by vickers hardness tester. The terms of this is Kg/mm2.
|
|
2174
|
+
|
|
2175
|
+
'''
|
|
2176
|
+
HV=1.854*F/(d**2)
|
|
2177
|
+
return HV
|
|
2178
|
+
|
|
2179
|
+
|
|
2180
|
+
|
|
2181
|
+
|
|
2182
|
+
|
|
2183
|
+
def Heat_Exchanger_Transfer(U,Th1,Th2,Tc1,Tc2,C,dot_m):
|
|
2184
|
+
'''
|
|
2185
|
+
|
|
2186
|
+
|
|
2187
|
+
Parameters
|
|
2188
|
+
----------
|
|
2189
|
+
U : float
|
|
2190
|
+
Overall heat transfer coefficient.
|
|
2191
|
+
Th1 : float
|
|
2192
|
+
Hot fluid inlet temperature.
|
|
2193
|
+
Th2 : float
|
|
2194
|
+
Hot fluid outlet temperature.
|
|
2195
|
+
Tc1 : float
|
|
2196
|
+
Cold fluid inlet temperature.
|
|
2197
|
+
Tc2 : float
|
|
2198
|
+
Cold fluid outlet temperature.
|
|
2199
|
+
C : float
|
|
2200
|
+
Special heat.
|
|
2201
|
+
dot_m : float
|
|
2202
|
+
Debbie Jeremy.
|
|
2203
|
+
|
|
2204
|
+
|
|
2205
|
+
Returns(delta_T_LMTD,Q,A)
|
|
2206
|
+
-------
|
|
2207
|
+
None.
|
|
2208
|
+
|
|
2209
|
+
|
|
2210
|
+
'''
|
|
2211
|
+
|
|
2212
|
+
delta_T_LMTD=((Th1-Tc2)-(Th2-Tc1))/math.log((Th1-Tc2)/(Th2-Tc1))##Logarithmic mean temperature
|
|
2213
|
+
|
|
2214
|
+
Q=dot_m*C*(Tc2-Tc1)
|
|
2215
|
+
|
|
2216
|
+
A=Q/(U*delta_T_LMTD)###The heat exchange surface used
|
|
2217
|
+
return delta_T_LMTD,A,Q
|
|
2218
|
+
|
|
2219
|
+
|
|
2220
|
+
|
|
2221
|
+
|
|
2222
|
+
def Ideal_Gas_low(R = "(L.atm) / (K.mol)", V = 1, n = 1, T = 0):
|
|
2223
|
+
|
|
2224
|
+
'''
|
|
2225
|
+
It calculate the Pressure of ideal gas.
|
|
2226
|
+
|
|
2227
|
+
Parameters:
|
|
2228
|
+
----------
|
|
2229
|
+
P : float
|
|
2230
|
+
Pressure
|
|
2231
|
+
|
|
2232
|
+
V : float
|
|
2233
|
+
The amount of Volume
|
|
2234
|
+
|
|
2235
|
+
n : float
|
|
2236
|
+
|
|
2237
|
+
The amount of substance
|
|
2238
|
+
|
|
2239
|
+
T : float
|
|
2240
|
+
Temperature
|
|
2241
|
+
|
|
2242
|
+
R : float
|
|
2243
|
+
ideal gas constant
|
|
2244
|
+
|
|
2245
|
+
'''
|
|
2246
|
+
# V in Litr, Pressure in atm, n in mol.
|
|
2247
|
+
if R == "(L * atm) / (K * mol)":
|
|
2248
|
+
P = (n * T * 0.082057) / V
|
|
2249
|
+
return P
|
|
2250
|
+
|
|
2251
|
+
if R == " J / (K.mol)":
|
|
2252
|
+
P = (n * T * 8.314472) / V
|
|
2253
|
+
return P
|
|
2254
|
+
|
|
2255
|
+
if R == "((m**3).atm) / (K.mol)":
|
|
2256
|
+
P = (n * T * 8.205745 * (10 **(-5))) / V
|
|
2257
|
+
return P
|
|
2258
|
+
|
|
2259
|
+
if R == "(L.kPa) / (K.mol)":
|
|
2260
|
+
P = (n * T * 8.314472) / V
|
|
2261
|
+
return P
|
|
2262
|
+
|
|
2263
|
+
if R == "(((m**3).Pa) / (K.mol))":
|
|
2264
|
+
P = (n * T * 8.314472) / V
|
|
2265
|
+
return P
|
|
2266
|
+
|
|
2267
|
+
if R == "((cm ** 3).atm) / (K.mol)":
|
|
2268
|
+
P = (n * T * 82.05745) / V
|
|
2269
|
+
return P
|
|
2270
|
+
|
|
2271
|
+
if R == "(L.mbar) / (K.mol)":
|
|
2272
|
+
P = (n * T * 83.14472) / V
|
|
2273
|
+
return P
|
|
2274
|
+
|
|
2275
|
+
if R == "((m**3).bar) / (K.mol)":
|
|
2276
|
+
P = (n * T * (8.314472 * (10**(-5)))) / V
|
|
2277
|
+
return P
|
|
2278
|
+
|
|
2279
|
+
|
|
2280
|
+
|
|
2281
|
+
|
|
2282
|
+
def ideal_gas_law(pressure, volume, temperature):
|
|
2283
|
+
gas_constant = 8.314 # Ideal gas constant
|
|
2284
|
+
return pressure * volume - gas_constant * temperature
|
|
2285
|
+
|
|
2286
|
+
|
|
2287
|
+
|
|
2288
|
+
|
|
2289
|
+
|
|
2290
|
+
def ideal_diode_equation(current, saturation_current, thermal_voltage):
|
|
2291
|
+
return current - saturation_current * (math.exp(current / thermal_voltage) - 1)
|
|
2292
|
+
|
|
2293
|
+
|
|
2294
|
+
|
|
2295
|
+
|
|
2296
|
+
def Income_Tax(a):
|
|
2297
|
+
"""
|
|
2298
|
+
|
|
2299
|
+
|
|
2300
|
+
Parameters
|
|
2301
|
+
----------
|
|
2302
|
+
a : float
|
|
2303
|
+
daramad fard dar yek mah
|
|
2304
|
+
|
|
2305
|
+
Returns maliyat bar daramad fard dar yek mah dar iran
|
|
2306
|
+
-------
|
|
2307
|
+
|
|
2308
|
+
|
|
2309
|
+
"""
|
|
2310
|
+
return (a-10000000)*0.09
|
|
2311
|
+
|
|
2312
|
+
|
|
2313
|
+
|
|
2314
|
+
def Incompressible_Fluids_Pressure(d,h):
|
|
2315
|
+
P_0=101325#(Pa)
|
|
2316
|
+
g=9.81#(m/s^2)
|
|
2317
|
+
P=d*g*h+P_0
|
|
2318
|
+
return P
|
|
2319
|
+
|
|
2320
|
+
|
|
2321
|
+
|
|
2322
|
+
|
|
2323
|
+
|
|
2324
|
+
def Insertion_Sort (non_sorted_list):
|
|
2325
|
+
|
|
2326
|
+
# key = non_sorted_list[0]
|
|
2327
|
+
for i in range(1, len(non_sorted_list)):
|
|
2328
|
+
key = non_sorted_list[i]
|
|
2329
|
+
# print ('key:',key)
|
|
2330
|
+
# print ('i:',i)
|
|
2331
|
+
j=i-1
|
|
2332
|
+
while j>=0 and key<non_sorted_list[j]:
|
|
2333
|
+
# print ('j:',j)
|
|
2334
|
+
# print ('key:',key)
|
|
2335
|
+
# if non_sorted_list[j]>key :
|
|
2336
|
+
non_sorted_list[j+1]=non_sorted_list[j]
|
|
2337
|
+
j-=1
|
|
2338
|
+
non_sorted_list[j+1]=key
|
|
2339
|
+
|
|
2340
|
+
print (non_sorted_list)
|
|
2341
|
+
return(non_sorted_list)
|
|
2342
|
+
|
|
2343
|
+
|
|
2344
|
+
|
|
2345
|
+
|
|
2346
|
+
def Indeterminate_degree_of_truss(m,j):
|
|
2347
|
+
'''
|
|
2348
|
+
This function calculates the degree of indeterminacy of the truss by taking 'm' number of truss members and 'j' number of nodes.
|
|
2349
|
+
|
|
2350
|
+
Parameters
|
|
2351
|
+
----------
|
|
2352
|
+
m : int
|
|
2353
|
+
Number of members truss.
|
|
2354
|
+
j : int
|
|
2355
|
+
Number truss node members.
|
|
2356
|
+
|
|
2357
|
+
Returns
|
|
2358
|
+
-------
|
|
2359
|
+
n : float
|
|
2360
|
+
The indeterminate degree of truss.
|
|
2361
|
+
|
|
2362
|
+
if n=0 : The truss is determinate.
|
|
2363
|
+
if n>0 : The truss is statically unstable.
|
|
2364
|
+
if n<0 : The truss is indeterminate.
|
|
2365
|
+
|
|
2366
|
+
'''
|
|
2367
|
+
Equations=2*j
|
|
2368
|
+
Unknowns=3+m
|
|
2369
|
+
global n
|
|
2370
|
+
if (Equations==Unknowns):
|
|
2371
|
+
n=0
|
|
2372
|
+
if Equations>Unknowns:
|
|
2373
|
+
n=Equations-Unknowns
|
|
2374
|
+
if Equations<Unknowns:
|
|
2375
|
+
n=Equations-Unknowns
|
|
2376
|
+
return n
|
|
2377
|
+
|
|
2378
|
+
|
|
2379
|
+
|
|
2380
|
+
|
|
2381
|
+
|
|
2382
|
+
|
|
2383
|
+
def kinetic_energy(mass, velocity):
|
|
2384
|
+
return 0.5 * mass * velocity**2
|
|
2385
|
+
|
|
2386
|
+
|
|
2387
|
+
|
|
2388
|
+
|
|
2389
|
+
def lorentz_force(charge, velocity, magnetic_field):
|
|
2390
|
+
return charge * (velocity.cross(magnetic_field))
|
|
2391
|
+
|
|
2392
|
+
|
|
2393
|
+
|
|
2394
|
+
|
|
2395
|
+
def Lorentz_Lorenz_Constant(n,ro):
|
|
2396
|
+
|
|
2397
|
+
''' n(float)= refrective index
|
|
2398
|
+
ro(float)=density g/cm3 or kg/m3
|
|
2399
|
+
|
|
2400
|
+
|
|
2401
|
+
Retuen:
|
|
2402
|
+
|
|
2403
|
+
R=(float)
|
|
2404
|
+
constant related to light properties of materials(polymers, plstics,...)
|
|
2405
|
+
|
|
2406
|
+
'''
|
|
2407
|
+
R=float((n**2-1)/(n**2+2)/ro)
|
|
2408
|
+
return R
|
|
2409
|
+
|
|
2410
|
+
|
|
2411
|
+
|
|
2412
|
+
|
|
2413
|
+
|
|
2414
|
+
def Latice_Parameter(structure, r):
|
|
2415
|
+
|
|
2416
|
+
'''
|
|
2417
|
+
this function calculates Latice parameter based on crystal structure.
|
|
2418
|
+
|
|
2419
|
+
Parametrs
|
|
2420
|
+
----------
|
|
2421
|
+
1. structure : str
|
|
2422
|
+
structure includes crystal structures such as FCC, BCC, SC, HCP, and DC.
|
|
2423
|
+
|
|
2424
|
+
FCC: face centered cubic
|
|
2425
|
+
BCC: body centered cubic
|
|
2426
|
+
SC: simple cubic
|
|
2427
|
+
HCP: hexagonal close pack
|
|
2428
|
+
DC: diamond cubic
|
|
2429
|
+
|
|
2430
|
+
2. r: float ---> (nm)
|
|
2431
|
+
r represents atomic radius.
|
|
2432
|
+
|
|
2433
|
+
Returns --> latice parameter (a)
|
|
2434
|
+
|
|
2435
|
+
'''
|
|
2436
|
+
|
|
2437
|
+
|
|
2438
|
+
|
|
2439
|
+
if structure == 'FCC' or 'face centered cubic':
|
|
2440
|
+
a = (4*r)/math.sqrt(2)
|
|
2441
|
+
|
|
2442
|
+
elif structure == 'BCC' or 'body centered cubic':
|
|
2443
|
+
a = (4*r)/math.sqrt(3)
|
|
2444
|
+
|
|
2445
|
+
elif structure == 'SC' or 'simple cubic':
|
|
2446
|
+
a = 2*r
|
|
2447
|
+
|
|
2448
|
+
elif structure == 'HCP' or 'hexagonal close pack':
|
|
2449
|
+
a = 2*r
|
|
2450
|
+
|
|
2451
|
+
elif structure == 'DC 'or 'diamond cubic':
|
|
2452
|
+
a = (8*r)/math.sqrt(3)
|
|
2453
|
+
|
|
2454
|
+
return a
|
|
2455
|
+
|
|
2456
|
+
|
|
2457
|
+
|
|
2458
|
+
|
|
2459
|
+
|
|
2460
|
+
def Lattice_Parameter(r,structure):
|
|
2461
|
+
'''
|
|
2462
|
+
Parameters
|
|
2463
|
+
----------
|
|
2464
|
+
r : float
|
|
2465
|
+
r is atomic radius of material. It is in terms of angestrom.
|
|
2466
|
+
structure : str
|
|
2467
|
+
Structure of material is face center cubic or body center cubic.
|
|
2468
|
+
|
|
2469
|
+
Returns
|
|
2470
|
+
-------
|
|
2471
|
+
a : float
|
|
2472
|
+
a is lattice parameter of material in unit cell. It is in terms of angestrom.
|
|
2473
|
+
|
|
2474
|
+
'''
|
|
2475
|
+
if structure=='fcc':
|
|
2476
|
+
a=4*r/(2**0.5)
|
|
2477
|
+
if structure=='bcc':
|
|
2478
|
+
a=4*r/(3**0.5)
|
|
2479
|
+
return a
|
|
2480
|
+
|
|
2481
|
+
|
|
2482
|
+
|
|
2483
|
+
|
|
2484
|
+
|
|
2485
|
+
|
|
2486
|
+
|
|
2487
|
+
|
|
2488
|
+
def Mandaliof_Properties(E):
|
|
2489
|
+
'''
|
|
2490
|
+
|
|
2491
|
+
|
|
2492
|
+
Parameters
|
|
2493
|
+
----------
|
|
2494
|
+
E : string
|
|
2495
|
+
The chemical symbol of the Element
|
|
2496
|
+
|
|
2497
|
+
Returns
|
|
2498
|
+
-------
|
|
2499
|
+
Nothing
|
|
2500
|
+
|
|
2501
|
+
'''
|
|
2502
|
+
PT=['H','He','Li','Be','B','C','N','O','F','Ne','Na','Mg','Al','Si','P','S','Cl','Ar','K','Ca','Sc','Ti','V','Cr','Mn','Fe','Co','Ni','Cu','Zn',
|
|
2503
|
+
'Ga','Ge','As','Se','Br','Kr','Rb','Sr','Y','Zr','Nb','Mo','Tc','Ru','Rh','Pd','Ag','Cd','In','Sn','Sb','Te','I','Xe','Cs','Ba','La','Ce','Pr',
|
|
2504
|
+
'Nd','Pm','Sm','Eu','Gd','Tb','Dy','Ho','Er','Tm','Yb','Lu','Hf','Ta','W','Re','Os','Ir','Pt','Au','Hg','Tl','Pb','Bi','Po','At','Rn','Fr','Ra',
|
|
2505
|
+
'Ac','Th','Pa','U','Np','Pu','Am','Cm','Bk','Cf','Es','Fm','Md','No','Lr','Rf','Db','Sg','Bh','Hs','Mt','Ds','Rg','Cn','Nh','Fl','Mc','Lv','Ts','Og']
|
|
2506
|
+
loc=PT.index(E)
|
|
2507
|
+
Column=[1,18,1,2,13,14,15,16,17,18,1,2,13,14,15,16,17,18,1,2,3,4,5,6,7,8,9,10,11,12,13,14,
|
|
2508
|
+
15,16,17,18,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,1,2,3,3,3,3,3,3,3,3,
|
|
2509
|
+
3,3,3,3,3,3,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,1,2,3,3,3,3,3,3,3,3,
|
|
2510
|
+
3,3,3,3,3,3,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18]
|
|
2511
|
+
Row=[1,1,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,
|
|
2512
|
+
5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,
|
|
2513
|
+
7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7]
|
|
2514
|
+
R=[31,28,128,112,84,76,71,66,57,58,166,141,121,111,107,105,102,106,203,176,170,160,153,139,139,132,152,124,132,122,122,120,
|
|
2515
|
+
119,120,120,116,220,195,190,175,164,154,147,146,142,139,145,144,142,139,139,138,139,140,244,215,207,204,203,201,199,198,198,196,
|
|
2516
|
+
194,192,192,189,190,187,187,175,170,162,151,144,141,136,136,132,145,146,148,140,150,150,260,221,215,206,200,186,190,187,180,169,
|
|
2517
|
+
168,'N/A','N/A','N/A','N/A','N/A','N/A','N/A','N/A','N/A','N/A','N/A','N/A','N/A','N/A','N/A','N/A','N/A','N/A','N/A','N/A','N/A']
|
|
2518
|
+
A_W=[1.008,4.003,6.94,9.012,10.81,12.01,14.007,15.999,18.998,20.180,22.990,24.305,26.981,28.085,30.974,32.06,35.45,39.948,39.098,40.078,44.956,47.867,50.941,51.996,54.938,55.845,58.933,58.693,63.546,65.38,69.723,72.63,
|
|
2519
|
+
74.922,78.971,79.904,83.798,85.468,87.62,88.906,91.224,92.906,95.95,98,101.07,102.906,106.42,107.868,112.414,114.818,118.71,121.76,127.6,126.904,131.293,132.905,137.327,138.905,140.116,140.908,144.242,145,150.36,151.964,157.25,
|
|
2520
|
+
158.925,162.5,164.930,167.259,168.934,173.045,174.967,178.49,180.948,183.84,186.207,190.23,192.217,195.084,196.967,200.592,204.38,207.2,208.980,209,210,222,223,226,227,232.038,231.036,238.029,237,244,243,247,
|
|
2521
|
+
247,251,252,257,258,259,262,267,270,269,270,270,278,281,281,285,286,289,289,293,293,294]
|
|
2522
|
+
T_m=[-259.14,'N/A',180.54,1287,2075,3550,-210.1,-218.3,-219.6,-248.59,97.72,650,660.32,1414,44.2,115.21,-101.5,-189.3,63.38,842,1541,1668,1910,1907,1246,1538,1495,1455,1084.62,419.53,29.76,938.3,
|
|
2523
|
+
817,221,-7.3,-157.36,39.31,777,1526,1855,2477,2623,2157,2334,1961,1554.9,961.78,321.07,156.6,231.93,630.63,449.51,113.7,-111.8,28.44,727,920,798,931,1021,1100,1072,822,1313,
|
|
2524
|
+
1356,1412,1474,1497,1545,819,1663,2233,3017,3422,3186,3033,2466,1768.3,1064.18,-38.83,304,327.46,271.3,254,302,-71,20.9,700,1050,1750,1572,1135,644,640,1176,1345,
|
|
2525
|
+
1050,900,860,1500,830,830,1600,'N/A','N/A','N/A','N/A','N/A','N/A','N/A','N/A','N/A','N/A','N/A','N/A','N/A','N/A','N/A']
|
|
2526
|
+
T_b=[-252.87,-268.93,1342,2470,4000,4027,-195.79,-182.9,-188.12,-246.08,883,1090,2519,2900,280.5,444.72,-34.04,-185.8,759,1484,2830,3287,3407,2671,2061,2861,2927,2913,2562,907,2204,2820,
|
|
2527
|
+
614,685,59,-153.22,688,1382,3345,4409,4744,4639,4265,4150,3695,2963,2162,767,2072,2602,1587,988,184.3,-108,671,1870,3464,3360,3290,3100,3000,1803,1527,3250,
|
|
2528
|
+
3230,2567,2700,2868,1950,1196,3402,4603,5458,5555,5596,5012,4428,3825,2856,356.73,1473,1749,1564,962,350,-61.7,650,1737,3200,4820,4000,3900,4000,3230,2011,3110,
|
|
2529
|
+
'N/A','N/A','N/A','N/A','N/A','N/A','N/A','N/A','N/A','N/A','N/A','N/A','N/A','N/A','N/A','N/A','N/A','N/A','N/A','N/A','N/A','N/A']
|
|
2530
|
+
Name=['Hydrogen','Helium','Lithium','Beryllium','Boron','Carbon','Nitrogen','Oxygen','Fluorine','Neon','Sodium','Magnesium','Aluminum','Silicon','Phosphorus','Sulfur','Chlorine','Argon','Potassium','Calcium','Scandium','Titanium','Vanadium','Chromium','Manganese','Iron','Cobalt','Nickel','Copper','Zinc','Gallium','Germanium',
|
|
2531
|
+
'Arsenic','Selenium','Bromine','Krypton','Rubidium','Strontium','Yttrium','Zirconium','Niobium','Molybdenum','Technetium','Ruthenium','Rhodium','Palladium','Silver','Cadmium','Indium','Tin','Antimony','Tellurium','Iodine','Xenon','Caesium','Barium','Lanthanum','Cerium','Praseodymium','Neodymium','Promethium','Samarium','Europium','Gadolinium',
|
|
2532
|
+
'Terbium','Dysprosium','Holmium','Erbium','Thulium','Ytterbium','Lutetium','Hafnium','Tantalum','Tungsten','Rhenium','Osmium','Iridium','Platinum','Gold','Mercury','Thallium','Lead','Bismuth','Polonium','Astatine','Radon','Francium','Radium','Actinium','Thorium','Protactinium','Uranium','Neptunium','Plutonium','Americium','Curium',
|
|
2533
|
+
'Berkelium','Californium','Einsteinium','Fermium','Mendelevium','Nobelium','Lawrencium','Rutherfordium','Dubnium','Seaborgium','Bohrium','Hassium','Meitnerium','Darmstadtium','Roentgenium','Copernicium','Nihonium','Flerovium','Moscovium','Livermorium','Tennessine','Oganesson']
|
|
2534
|
+
|
|
2535
|
+
if loc>95:
|
|
2536
|
+
P='Solid'
|
|
2537
|
+
elif loc==1:
|
|
2538
|
+
P='Gas'
|
|
2539
|
+
else:
|
|
2540
|
+
if 25<T_m[loc]:
|
|
2541
|
+
P='Solid'
|
|
2542
|
+
elif T_m[loc]<25<T_b[loc]:
|
|
2543
|
+
P='Liquid'
|
|
2544
|
+
else:
|
|
2545
|
+
P='Gas'
|
|
2546
|
+
print('The properties of the element you are looking for are:\n\n\nFull name: ',Name[loc],'\nLocation in Periodic Table: Row=',Row[loc],' Column=',Column[loc],
|
|
2547
|
+
'\nAtomic number: ',loc+1,'\nAtomic weight: ',A_W[loc],' g/mol\nAtomic radius: ',R[loc],' pm\nMelting temperature: ',T_m[loc],end='')
|
|
2548
|
+
if loc==32:
|
|
2549
|
+
print(' (Above 28 atm)',end='')
|
|
2550
|
+
print('\nBoiling temperature: ',T_b[loc],' \nStandard phase: ',P)
|
|
2551
|
+
|
|
2552
|
+
|
|
2553
|
+
|
|
2554
|
+
|
|
2555
|
+
|
|
2556
|
+
def Mtt_Test(C1,C2):
|
|
2557
|
+
'''
|
|
2558
|
+
This function measures the metabolic activity of the cell
|
|
2559
|
+
|
|
2560
|
+
Parameters
|
|
2561
|
+
----------
|
|
2562
|
+
C1 : int
|
|
2563
|
+
viable cells
|
|
2564
|
+
C2 : int
|
|
2565
|
+
total cells
|
|
2566
|
+
|
|
2567
|
+
Returns
|
|
2568
|
+
float
|
|
2569
|
+
Mtt_Test
|
|
2570
|
+
|
|
2571
|
+
'''
|
|
2572
|
+
|
|
2573
|
+
|
|
2574
|
+
return (C1/C2)*100
|
|
2575
|
+
|
|
2576
|
+
|
|
2577
|
+
|
|
2578
|
+
def mass_energy_equivalence(mass):
|
|
2579
|
+
speed_of_light = 3e8 # Speed of light in m/s
|
|
2580
|
+
return mass * speed_of_light**2
|
|
2581
|
+
|
|
2582
|
+
|
|
2583
|
+
|
|
2584
|
+
|
|
2585
|
+
def maxwells_equations(electric_field, magnetic_field, charge_density, current_density):
|
|
2586
|
+
return electric_field.div() - charge_density, magnetic_field.curl() - current_density
|
|
2587
|
+
|
|
2588
|
+
|
|
2589
|
+
|
|
2590
|
+
|
|
2591
|
+
|
|
2592
|
+
def Mc_Cabe(F,Zf,Xd,Xw,R,alpha,q):
|
|
2593
|
+
'''This function is used for Mc-Cabe calculation in Distillation Towers
|
|
2594
|
+
F : Feed Rate
|
|
2595
|
+
Zf : volatile composition in Feed
|
|
2596
|
+
Xd : volatile composition in Distillate
|
|
2597
|
+
Xw : volatile composition in Waste
|
|
2598
|
+
R : Reflux
|
|
2599
|
+
alpha : Volatility coefficient
|
|
2600
|
+
q : the quantity of liquid in feed
|
|
2601
|
+
Returns the number of tray'''
|
|
2602
|
+
W=F*(Xd-Zf)/(Xd-Xw)
|
|
2603
|
+
D=F-W
|
|
2604
|
+
L_first=R*D
|
|
2605
|
+
G_first=(R+1)*D
|
|
2606
|
+
L_second=L_first+q*F
|
|
2607
|
+
G_second=G_first-(1-q)*F
|
|
2608
|
+
# Rmin Calculation
|
|
2609
|
+
guess=0
|
|
2610
|
+
n=0
|
|
2611
|
+
while n<10000:
|
|
2612
|
+
if q==0:
|
|
2613
|
+
Left=np.array([Zf/(1-Zf)])
|
|
2614
|
+
Right=np.array([alpha*((Xd*(q-1)+Zf*(guess+1))/(((1-Xd)*(q-1))+(1-Zf)*(guess+1)))])
|
|
2615
|
+
else:
|
|
2616
|
+
Left=np.array([((Xd*q+Zf*guess)/((1-Xd)*q+(1-Zf)*guess))])
|
|
2617
|
+
Right=np.array([alpha*((Xd*(q-1)+Zf*(guess+1))/(((1-Xd)*(q-1))+(1-Zf)*(guess+1)))])
|
|
2618
|
+
if Left-Right<0:
|
|
2619
|
+
Rmin=guess
|
|
2620
|
+
else:
|
|
2621
|
+
guess=guess+0.001
|
|
2622
|
+
n=n+1
|
|
2623
|
+
|
|
2624
|
+
# Nmin Calculation
|
|
2625
|
+
Nmin=np.ceil(math.log((Xd*(1-Xw))/(Xw*(1-Xd)),10)/(math.log(alpha,10))-1)
|
|
2626
|
+
|
|
2627
|
+
# N Calculation
|
|
2628
|
+
# 1st Operating Line
|
|
2629
|
+
x=np.array([])
|
|
2630
|
+
for i in range(0,101,1):
|
|
2631
|
+
a=np.array([i/100])
|
|
2632
|
+
x=np.concatenate((x,a))
|
|
2633
|
+
|
|
2634
|
+
yeq=np.array([])
|
|
2635
|
+
for i in range(0,101,1):
|
|
2636
|
+
b=np.array([(alpha*(i/100))/((alpha-1)*(i/100)+1)])
|
|
2637
|
+
yeq=np.concatenate((yeq,b))
|
|
2638
|
+
|
|
2639
|
+
y_first=np.array([])
|
|
2640
|
+
for i in range(0,101,1):
|
|
2641
|
+
c=np.array([(((R*(i/100))/(R+1))+((Xd)/(R+1)))])
|
|
2642
|
+
y_first=np.concatenate((y_first,c))
|
|
2643
|
+
|
|
2644
|
+
y_second=np.array([])
|
|
2645
|
+
for i in range(0,101,1):
|
|
2646
|
+
d=np.array([L_second*(i/100)/G_second-W*Xw/G_second])
|
|
2647
|
+
y_second=np.concatenate((y_second,d))
|
|
2648
|
+
|
|
2649
|
+
xfeed=np.array([])
|
|
2650
|
+
for i in range(0,101,1):
|
|
2651
|
+
if q==1:
|
|
2652
|
+
e=np.array([Zf])
|
|
2653
|
+
xfeed=np.concatenate((xfeed,e))
|
|
2654
|
+
else:
|
|
2655
|
+
e=np.array([i/100])
|
|
2656
|
+
xfeed=np.concatenate((xfeed,e))
|
|
2657
|
+
|
|
2658
|
+
yfeed=np.array([])
|
|
2659
|
+
for i in range(0,101,1):
|
|
2660
|
+
if q==1:
|
|
2661
|
+
m=np.array([i/100])
|
|
2662
|
+
yfeed=np.concatenate((yfeed,m))
|
|
2663
|
+
else:
|
|
2664
|
+
f=np.array([((q*(i/100))/(q-1))-(Zf/(q-1))])
|
|
2665
|
+
yfeed=np.concatenate((yfeed,f))
|
|
2666
|
+
|
|
2667
|
+
if q==1:
|
|
2668
|
+
xcrosspoint=Zf
|
|
2669
|
+
ycrosspoint=(L_first*xcrosspoint)/(G_first)+Xd/(R+1)
|
|
2670
|
+
else:
|
|
2671
|
+
xcrosspoint=((Zf/(q-1))+(Xd/(R+1)))/((q/(q-1))-(L_first/G_first))
|
|
2672
|
+
ycrosspoint=(q*xcrosspoint)/(q-1)-(Zf/(q-1))
|
|
2673
|
+
|
|
2674
|
+
Xopt=[]
|
|
2675
|
+
x=Xd
|
|
2676
|
+
for i in range(0,100):
|
|
2677
|
+
if ycrosspoint<x:
|
|
2678
|
+
xopt=x/(alpha+x-alpha*x)
|
|
2679
|
+
x=(L_first*xopt/G_first)+(Xd/(R+1))
|
|
2680
|
+
Xopt=Xopt+[xopt]
|
|
2681
|
+
Nfeed=len(Xopt)
|
|
2682
|
+
elif x>Xw:
|
|
2683
|
+
xopt=x/(alpha+x-alpha*x)
|
|
2684
|
+
x=(L_second*xopt/G_second)-W*Xw/G_second
|
|
2685
|
+
Xopt=Xopt+[xopt]
|
|
2686
|
+
else:
|
|
2687
|
+
N=len(Xopt)-1
|
|
2688
|
+
return print('Nmin=',Nmin,' Rmin=',Rmin,' N=',N,' NFeed=',Nfeed,' W=',W,' D=',D)
|
|
2689
|
+
|
|
2690
|
+
|
|
2691
|
+
|
|
2692
|
+
|
|
2693
|
+
|
|
2694
|
+
def Mass_Transfer_Intensity(result_1, size_of_the_surface):
|
|
2695
|
+
MTI_ἠ = float(result_1 * size_of_the_surface) #The size of the surface where mass transfer occurs(unite Meter).
|
|
2696
|
+
|
|
2697
|
+
return MTI_ἠ
|
|
2698
|
+
|
|
2699
|
+
|
|
2700
|
+
|
|
2701
|
+
|
|
2702
|
+
def Mass_Plating(num1,num2,num3,num4):
|
|
2703
|
+
'''
|
|
2704
|
+
|
|
2705
|
+
|
|
2706
|
+
Parameters
|
|
2707
|
+
----------
|
|
2708
|
+
num1 : float
|
|
2709
|
+
current(A).
|
|
2710
|
+
num2 : float
|
|
2711
|
+
time(s).
|
|
2712
|
+
num3 : floar
|
|
2713
|
+
molar mass(g/mol).
|
|
2714
|
+
num4 : int
|
|
2715
|
+
number of electron.
|
|
2716
|
+
|
|
2717
|
+
Returns
|
|
2718
|
+
precipitation mass in plating in g unit.
|
|
2719
|
+
|
|
2720
|
+
'''
|
|
2721
|
+
m = num1*num2*num3/(num4*F)
|
|
2722
|
+
return m
|
|
2723
|
+
|
|
2724
|
+
|
|
2725
|
+
|
|
2726
|
+
|
|
2727
|
+
|
|
2728
|
+
def Mass_Of_Rubber_In_Internal_Mixer(filler_percentage,type_of_rotors,V):
|
|
2729
|
+
if filler_percentage>65:
|
|
2730
|
+
if type_of_rotors=='tangential':
|
|
2731
|
+
M=1.3*0.8*V
|
|
2732
|
+
return M
|
|
2733
|
+
|
|
2734
|
+
if type_of_rotors=='intermix':
|
|
2735
|
+
M=1.3*0.6*V
|
|
2736
|
+
return M
|
|
2737
|
+
|
|
2738
|
+
if filler_percentage<=65:
|
|
2739
|
+
if type_of_rotors=='tangential':
|
|
2740
|
+
M=1*0.8*V
|
|
2741
|
+
return M
|
|
2742
|
+
|
|
2743
|
+
if type_of_rotors=='intermix':
|
|
2744
|
+
M=1*0.6*V
|
|
2745
|
+
return M
|
|
2746
|
+
|
|
2747
|
+
|
|
2748
|
+
def Miner_Rule_Fatigue(n,N):
|
|
2749
|
+
'''
|
|
2750
|
+
|
|
2751
|
+
|
|
2752
|
+
Parameters
|
|
2753
|
+
----------
|
|
2754
|
+
n : list
|
|
2755
|
+
number of cycles at stress level
|
|
2756
|
+
|
|
2757
|
+
N : list
|
|
2758
|
+
number of cycles to failure at stress level
|
|
2759
|
+
|
|
2760
|
+
Returns
|
|
2761
|
+
-------
|
|
2762
|
+
sigma : float
|
|
2763
|
+
|
|
2764
|
+
'''
|
|
2765
|
+
sigma=0
|
|
2766
|
+
for i in range(0,len(n)):
|
|
2767
|
+
for j in range(0,len(N)):
|
|
2768
|
+
if i==j:
|
|
2769
|
+
sigma=sigma+(n[i]/N[j])
|
|
2770
|
+
|
|
2771
|
+
if sigma<1:
|
|
2772
|
+
print("There is no fatigue yet")
|
|
2773
|
+
elif sigma>=1:
|
|
2774
|
+
print("Failure occurs at least according to Miner's rule")
|
|
2775
|
+
|
|
2776
|
+
return sigma
|
|
2777
|
+
|
|
2778
|
+
|
|
2779
|
+
|
|
2780
|
+
|
|
2781
|
+
def Nanoparticle_Surface_Area(Shape,Diameter=0,a=0):
|
|
2782
|
+
"""
|
|
2783
|
+
Calculating the surface area of nanoparticle by determinig the shape
|
|
2784
|
+
|
|
2785
|
+
Parameters
|
|
2786
|
+
----------
|
|
2787
|
+
Shape:str
|
|
2788
|
+
(sphere,cube or tetrahedron)
|
|
2789
|
+
|
|
2790
|
+
Diameter : int
|
|
2791
|
+
DESCRIPTION. The default is 0.
|
|
2792
|
+
(it is needed for spherical nanoparticles)
|
|
2793
|
+
unit(nm)
|
|
2794
|
+
|
|
2795
|
+
a : int
|
|
2796
|
+
dimention
|
|
2797
|
+
unit(nm)
|
|
2798
|
+
DESCRIPTION. The default is 0.
|
|
2799
|
+
(it is needed for cubic or tetragonal nanoparticles)
|
|
2800
|
+
unit(nm)
|
|
2801
|
+
|
|
2802
|
+
Returns
|
|
2803
|
+
-------
|
|
2804
|
+
Nanoparticle_Surface_Area : int
|
|
2805
|
+
unit(nm^2)
|
|
2806
|
+
|
|
2807
|
+
"""
|
|
2808
|
+
Shape=input('enter the shape of nanoparticle')
|
|
2809
|
+
if Shape=='sphere':
|
|
2810
|
+
Diameter=int(input('enter the shape of nanoparticles diameter'))
|
|
2811
|
+
Nanoparticle_Surface_Area=math.pi*(Diameter**2)
|
|
2812
|
+
print(Nanoparticle_Surface_Area)
|
|
2813
|
+
return Nanoparticle_Surface_Area
|
|
2814
|
+
elif Shape=='cube':
|
|
2815
|
+
a=int(input('enter a '))
|
|
2816
|
+
Nanoparticle_Surface_Area=6*(a**2)
|
|
2817
|
+
print(Nanoparticle_Surface_Area)
|
|
2818
|
+
return Nanoparticle_Surface_Area
|
|
2819
|
+
elif Shape=='tetrahedron':
|
|
2820
|
+
a=int(input('enter a '))
|
|
2821
|
+
Nanoparticle_Surface_Area=(3**0.5)*(a**2)
|
|
2822
|
+
print(Nanoparticle_Surface_Area)
|
|
2823
|
+
return Nanoparticle_Surface_Area
|
|
2824
|
+
else:
|
|
2825
|
+
print('please retry and enter the needed parameters corectly')
|
|
2826
|
+
|
|
2827
|
+
|
|
2828
|
+
|
|
2829
|
+
|
|
2830
|
+
|
|
2831
|
+
def Nanoparticle_Aspect_Ratio(lenght=1,width=1,height=1):
|
|
2832
|
+
"""
|
|
2833
|
+
Calculating the Nanoparticle_Aspect_Ratio
|
|
2834
|
+
|
|
2835
|
+
Parameters
|
|
2836
|
+
----------
|
|
2837
|
+
lenght : int
|
|
2838
|
+
lenght of a nanoparticle
|
|
2839
|
+
DESCRIPTION. The default is 1.
|
|
2840
|
+
unit(nm)
|
|
2841
|
+
width : int
|
|
2842
|
+
width of a nanoparticle
|
|
2843
|
+
DESCRIPTION. The default is 1.
|
|
2844
|
+
unit(nm)
|
|
2845
|
+
height : int
|
|
2846
|
+
height of a nanoparticle
|
|
2847
|
+
DESCRIPTION. The default is 1.
|
|
2848
|
+
unit(nm)
|
|
2849
|
+
|
|
2850
|
+
Returns
|
|
2851
|
+
-------
|
|
2852
|
+
Nanoparticle_Aspect_Ratio : float
|
|
2853
|
+
the ratio of maximum dimention of a nanoparticle to minimum dimention of it.
|
|
2854
|
+
|
|
2855
|
+
"""
|
|
2856
|
+
lenght=int(input('please enter lenght'))
|
|
2857
|
+
width=int(input('please enter width'))
|
|
2858
|
+
height=int(input('please enter height'))
|
|
2859
|
+
maximum=max(lenght,width,height)
|
|
2860
|
+
minimum=min(lenght,width,height)
|
|
2861
|
+
Nanoparticle_Aspect_Ratio=maximum/minimum
|
|
2862
|
+
print('Nanoparticle_Aspect_Ratio=',Nanoparticle_Aspect_Ratio)
|
|
2863
|
+
return Nanoparticle_Aspect_Ratio
|
|
2864
|
+
|
|
2865
|
+
|
|
2866
|
+
|
|
2867
|
+
|
|
2868
|
+
def Nanoparticle_Volume(Shape,Diameter=0,a=0):
|
|
2869
|
+
"""
|
|
2870
|
+
Calculating the Volume of a nanoparticle by determinig the shape
|
|
2871
|
+
|
|
2872
|
+
Parameters
|
|
2873
|
+
----------
|
|
2874
|
+
Shape:str
|
|
2875
|
+
(sphere,cube or tetrahedron)
|
|
2876
|
+
|
|
2877
|
+
Diameter : int
|
|
2878
|
+
DESCRIPTION. The default is 0.
|
|
2879
|
+
(it is needed for spherical nanoparticles)
|
|
2880
|
+
unit(nm)
|
|
2881
|
+
|
|
2882
|
+
a : int
|
|
2883
|
+
dimention
|
|
2884
|
+
unit(nm)
|
|
2885
|
+
DESCRIPTION. The default is 0.
|
|
2886
|
+
(it is needed for cubic or tetragonal nanoparticles)
|
|
2887
|
+
unit(nm)
|
|
2888
|
+
|
|
2889
|
+
Returns
|
|
2890
|
+
-------
|
|
2891
|
+
Nanoparticle_Volume : int
|
|
2892
|
+
unit(nm^3)
|
|
2893
|
+
|
|
2894
|
+
"""
|
|
2895
|
+
Shape=input('enter the shape of nanoparticle')
|
|
2896
|
+
if Shape=='sphere':
|
|
2897
|
+
Diameter=int(input('enter the shape of nanoparticles diameter'))
|
|
2898
|
+
Nanoparticle_Volume=math.pi*((Diameter**3)/6)
|
|
2899
|
+
print(Nanoparticle_Volume)
|
|
2900
|
+
return Nanoparticle_Volume
|
|
2901
|
+
elif Shape=='cube':
|
|
2902
|
+
a=int(input('enter a '))
|
|
2903
|
+
Nanoparticle_Volume=a**3
|
|
2904
|
+
print(Nanoparticle_Volume)
|
|
2905
|
+
return Nanoparticle_Volume
|
|
2906
|
+
elif Shape=='tetrahedron':
|
|
2907
|
+
a=int(input('enter a '))
|
|
2908
|
+
Nanoparticle_Volume=(2**0.5)*(a**3)/12
|
|
2909
|
+
print(Nanoparticle_Volume)
|
|
2910
|
+
return Nanoparticle_Volume
|
|
2911
|
+
else:
|
|
2912
|
+
print('please retry and enter the needed parameters corectly')
|
|
2913
|
+
|
|
2914
|
+
|
|
2915
|
+
|
|
2916
|
+
|
|
2917
|
+
|
|
2918
|
+
|
|
2919
|
+
|
|
2920
|
+
def newtons_second_law(force, mass, acceleration):
|
|
2921
|
+
return force - mass * acceleration
|
|
2922
|
+
|
|
2923
|
+
|
|
2924
|
+
|
|
2925
|
+
|
|
2926
|
+
|
|
2927
|
+
|
|
2928
|
+
def ohms_law(voltage, current, resistance):
|
|
2929
|
+
return voltage - current * resistance
|
|
2930
|
+
|
|
2931
|
+
|
|
2932
|
+
|
|
2933
|
+
|
|
2934
|
+
def poisson(transverse_strain,axial_strain):
|
|
2935
|
+
v=-(transverse_strain/axial_strain)
|
|
2936
|
+
return v
|
|
2937
|
+
|
|
2938
|
+
|
|
2939
|
+
|
|
2940
|
+
|
|
2941
|
+
|
|
2942
|
+
def pH_Which (pH):
|
|
2943
|
+
if pH<7:
|
|
2944
|
+
print ('This solution is acidic')
|
|
2945
|
+
elif pH ==7:
|
|
2946
|
+
print ('This solution is neutral')
|
|
2947
|
+
elif pH>7:
|
|
2948
|
+
print('This solution is basic')
|
|
2949
|
+
|
|
2950
|
+
|
|
2951
|
+
|
|
2952
|
+
|
|
2953
|
+
|
|
2954
|
+
def Principal_Stress(Sx,Sy,Sz,Txy,Tyz,Txz):
|
|
2955
|
+
'''
|
|
2956
|
+
make sure stress value is less than 1000
|
|
2957
|
+
Parameters
|
|
2958
|
+
----------
|
|
2959
|
+
Sx : (int or float)
|
|
2960
|
+
Normal stress along x
|
|
2961
|
+
Sy : (int or float)
|
|
2962
|
+
Normal stress along y
|
|
2963
|
+
Sz : (int or float)
|
|
2964
|
+
Normal stress along z
|
|
2965
|
+
Txy : (int or float)
|
|
2966
|
+
Shear stress along xy
|
|
2967
|
+
Tyz : (int or float)
|
|
2968
|
+
Shear stress along yz
|
|
2969
|
+
Txz : (int or float)
|
|
2970
|
+
Shear stress along xz
|
|
2971
|
+
Returns
|
|
2972
|
+
-------
|
|
2973
|
+
S_P : [S1,S2,S3]
|
|
2974
|
+
Principal stresses
|
|
2975
|
+
|
|
2976
|
+
'''
|
|
2977
|
+
|
|
2978
|
+
|
|
2979
|
+
a=1
|
|
2980
|
+
b=Sx+Sy+Sz
|
|
2981
|
+
c=Sx*Sy+Sy*Sz+Sx*Sz-Txy**2-Tyz**2-Txz**2
|
|
2982
|
+
d=Sx*Sy*Sz+2*Txy*Tyz*Txz-Sx*Tyz**2-Sy*Txz**2-Sz*Txy**2
|
|
2983
|
+
|
|
2984
|
+
|
|
2985
|
+
# aS^3-bS^2+cS-d=0
|
|
2986
|
+
|
|
2987
|
+
S_P=[0,0,0]
|
|
2988
|
+
#-------------Numerical Calculation---------------
|
|
2989
|
+
sp=0
|
|
2990
|
+
for i in range(2001):
|
|
2991
|
+
x0=-1000+i
|
|
2992
|
+
f0=a*x0**3-b*x0**2+c*x0-d
|
|
2993
|
+
x1=x0+1
|
|
2994
|
+
f1=a*x1**3-b*x1**2+c*x1-d
|
|
2995
|
+
if f0>-10 and f0<10:
|
|
2996
|
+
S_P[sp]=x0
|
|
2997
|
+
if sp==2:
|
|
2998
|
+
break
|
|
2999
|
+
sp=sp+1
|
|
3000
|
+
else:
|
|
3001
|
+
if f0*f1<0:
|
|
3002
|
+
while i>-1:
|
|
3003
|
+
x=(x0+x1)/2
|
|
3004
|
+
f=a*x**3-b*x**2+c*x-d
|
|
3005
|
+
if f>-10 and f<10:
|
|
3006
|
+
S_P[sp]=x
|
|
3007
|
+
if sp==2:
|
|
3008
|
+
break
|
|
3009
|
+
sp=sp+1
|
|
3010
|
+
break
|
|
3011
|
+
elif f0*f<0:
|
|
3012
|
+
x1=x
|
|
3013
|
+
f1=f
|
|
3014
|
+
else:
|
|
3015
|
+
x0=x
|
|
3016
|
+
f0=f
|
|
3017
|
+
else:
|
|
3018
|
+
continue
|
|
3019
|
+
|
|
3020
|
+
|
|
3021
|
+
return S_P
|
|
3022
|
+
|
|
3023
|
+
|
|
3024
|
+
|
|
3025
|
+
|
|
3026
|
+
|
|
3027
|
+
def Pythagorean(side1,side2):
|
|
3028
|
+
'''
|
|
3029
|
+
It should be an orthogonal triangle and this function gives you hypotenuse
|
|
3030
|
+
|
|
3031
|
+
Parameters
|
|
3032
|
+
----------
|
|
3033
|
+
side1 : int
|
|
3034
|
+
side of "orthogonal triangle".
|
|
3035
|
+
side2 : int
|
|
3036
|
+
side of "orthogonal triangle".
|
|
3037
|
+
|
|
3038
|
+
Returns
|
|
3039
|
+
-------
|
|
3040
|
+
hypotenuse: int
|
|
3041
|
+
hypotenuse of "orthogonal triangle".
|
|
3042
|
+
|
|
3043
|
+
'''
|
|
3044
|
+
hypotenuse =((side1**2)+(side2**2))**(1/2)
|
|
3045
|
+
return hypotenuse
|
|
3046
|
+
|
|
3047
|
+
|
|
3048
|
+
|
|
3049
|
+
|
|
3050
|
+
|
|
3051
|
+
def pythagorean_theorem(a, b):
|
|
3052
|
+
return (a**2 + b**2)**0.5
|
|
3053
|
+
|
|
3054
|
+
|
|
3055
|
+
|
|
3056
|
+
|
|
3057
|
+
def photoelectric_effect(kinetic_energy, photon_energy, work_function):
|
|
3058
|
+
return kinetic_energy - (photon_energy - work_function)
|
|
3059
|
+
|
|
3060
|
+
|
|
3061
|
+
|
|
3062
|
+
|
|
3063
|
+
|
|
3064
|
+
def is_Pythagorean(a,b,c):
|
|
3065
|
+
"""
|
|
3066
|
+
|
|
3067
|
+
|
|
3068
|
+
Parameters
|
|
3069
|
+
----------
|
|
3070
|
+
a : float
|
|
3071
|
+
tool zele aval.
|
|
3072
|
+
b : float
|
|
3073
|
+
tool zele dovom.
|
|
3074
|
+
c : float
|
|
3075
|
+
tool zele sevom.
|
|
3076
|
+
|
|
3077
|
+
Returns be ma mige in adad mitoonan mosalas ghaem alazviye tashkil bedan
|
|
3078
|
+
ba "mosalas ghaemalzaviye mishe" va" mosalas ghaemalzaviye nemishe"
|
|
3079
|
+
-------
|
|
3080
|
+
|
|
3081
|
+
"""
|
|
3082
|
+
if a**2==b**2+c**2 or b**2==a**2+c**2 or c**2==a**2+b**2:
|
|
3083
|
+
return True
|
|
3084
|
+
else:
|
|
3085
|
+
return False
|
|
3086
|
+
|
|
3087
|
+
|
|
3088
|
+
|
|
3089
|
+
|
|
3090
|
+
def Polygonal_Diameters(n):
|
|
3091
|
+
"""
|
|
3092
|
+
|
|
3093
|
+
|
|
3094
|
+
Parameters
|
|
3095
|
+
----------
|
|
3096
|
+
n : int
|
|
3097
|
+
tedad azlae chand zelei(az 2 ta bishtar).
|
|
3098
|
+
|
|
3099
|
+
Returns tedad ghotrhaye chand zelei
|
|
3100
|
+
-------
|
|
3101
|
+
|
|
3102
|
+
"""
|
|
3103
|
+
return((n*(n-3))/2)
|
|
3104
|
+
|
|
3105
|
+
|
|
3106
|
+
|
|
3107
|
+
|
|
3108
|
+
def PengRobinson(T = None,P = None,Tc = None,Pc = None,w = None,MW = None,Phases = None):
|
|
3109
|
+
"""
|
|
3110
|
+
PengRobinson.m : calculates the compressibility factor,fugacity coefficient and density
|
|
3111
|
+
of a pure compound with the Peng Robinson equation of state (PR EOS)
|
|
3112
|
+
|
|
3113
|
+
Parameters
|
|
3114
|
+
----------
|
|
3115
|
+
T : float
|
|
3116
|
+
Temperature [=] K
|
|
3117
|
+
P : float
|
|
3118
|
+
Presure [=] Pa
|
|
3119
|
+
Tc : float
|
|
3120
|
+
Critical temperature [=] K
|
|
3121
|
+
Pc : float
|
|
3122
|
+
Critical presure [=] Pa
|
|
3123
|
+
w : float
|
|
3124
|
+
Accentic factor
|
|
3125
|
+
MW : float
|
|
3126
|
+
Molar weigth [=] kg/mol.
|
|
3127
|
+
Phases : int
|
|
3128
|
+
if Phases == 1, then calculates liquid fugacity;
|
|
3129
|
+
if Phases == 0 then calculates vapor fugacity
|
|
3130
|
+
|
|
3131
|
+
Returns
|
|
3132
|
+
-------
|
|
3133
|
+
Z : flout
|
|
3134
|
+
Compressibility factor
|
|
3135
|
+
fhi : float
|
|
3136
|
+
Fugacity coefficient
|
|
3137
|
+
density : float
|
|
3138
|
+
Density
|
|
3139
|
+
|
|
3140
|
+
"""
|
|
3141
|
+
R = 8.314
|
|
3142
|
+
|
|
3143
|
+
# Reduced variables
|
|
3144
|
+
Tr = T / Tc
|
|
3145
|
+
|
|
3146
|
+
# Parameters of the EOS for a pure component
|
|
3147
|
+
m = 0.37464 + 1.54226 * w - 0.26992 * w ** 2
|
|
3148
|
+
alfa = (1 + m * (1 - np.sqrt(Tr))) ** 2
|
|
3149
|
+
a = 0.45724 * (R * Tc) ** 2 / Pc * alfa
|
|
3150
|
+
b = 0.0778 * R * Tc / Pc
|
|
3151
|
+
A = a * P / (R * T) ** 2
|
|
3152
|
+
B = b * P / (R * T)
|
|
3153
|
+
# Compressibility factor
|
|
3154
|
+
Z = np.roots(np.array([1,- (1 - B),(A - 3 * B ** 2 - 2 * B),- (A * B - B ** 2 - B ** 3)]))
|
|
3155
|
+
ZR = []
|
|
3156
|
+
for i in range(3):
|
|
3157
|
+
if type(Z[i])!='complex':
|
|
3158
|
+
ZR.append(Z[i])
|
|
3159
|
+
|
|
3160
|
+
if Phases == 1:
|
|
3161
|
+
Z = np.amin(ZR)
|
|
3162
|
+
else:
|
|
3163
|
+
Z = np.amax(ZR)
|
|
3164
|
+
|
|
3165
|
+
# Fugacity coefficient
|
|
3166
|
+
fhi = np.exp(Z - 1 - np.log(Z - B) - A / (2 * B * np.sqrt(2)) * np.log((Z + (1 + np.sqrt(2)) * B) / (Z + (1 - np.sqrt(2)) * B)))
|
|
3167
|
+
if True:
|
|
3168
|
+
density = P * MW / (Z * R * T)
|
|
3169
|
+
result = np.array([Z,fhi,density])
|
|
3170
|
+
else:
|
|
3171
|
+
'No real solution for "fhi" is available in this phase'
|
|
3172
|
+
result = np.array(['N/A','N/A','N/A'])
|
|
3173
|
+
|
|
3174
|
+
|
|
3175
|
+
return result
|
|
3176
|
+
|
|
3177
|
+
|
|
3178
|
+
|
|
3179
|
+
|
|
3180
|
+
|
|
3181
|
+
|
|
3182
|
+
def Planks_Fix(y,R,r):
|
|
3183
|
+
'''
|
|
3184
|
+
This formula is used to calculate the wall pressure of bleeding in the veins
|
|
3185
|
+
This function receives the variables y, r, R and returns the variable p
|
|
3186
|
+
p:It indicates the pressure of the bleeding wall.
|
|
3187
|
+
y:Surface coefficient is surface tension
|
|
3188
|
+
R:is the inner radius of the vessel.
|
|
3189
|
+
r:is the thickness of the vessel wall.
|
|
3190
|
+
'''
|
|
3191
|
+
p=2*y*R/r
|
|
3192
|
+
return p
|
|
3193
|
+
|
|
3194
|
+
|
|
3195
|
+
|
|
3196
|
+
|
|
3197
|
+
|
|
3198
|
+
def Power_Factor(i,v):
|
|
3199
|
+
'''
|
|
3200
|
+
Parameters
|
|
3201
|
+
----------
|
|
3202
|
+
This function receives the variables i, v and returns the variable P
|
|
3203
|
+
i : int
|
|
3204
|
+
It is an electric current that passes through a circuit
|
|
3205
|
+
v : int
|
|
3206
|
+
It is an electric current that passes through a circuit
|
|
3207
|
+
p : int
|
|
3208
|
+
It indicates the power used or produced.
|
|
3209
|
+
|
|
3210
|
+
'''
|
|
3211
|
+
p=i*v
|
|
3212
|
+
return p
|
|
3213
|
+
|
|
3214
|
+
|
|
3215
|
+
|
|
3216
|
+
|
|
3217
|
+
|
|
3218
|
+
|
|
3219
|
+
def Print_Time(Print_speed,Volume,Printer_efficiency):
|
|
3220
|
+
|
|
3221
|
+
''' volume(float)= usually Cm3
|
|
3222
|
+
|
|
3223
|
+
print_speed(float)= and is speed of print usually cm3 per hour)
|
|
3224
|
+
|
|
3225
|
+
Printer_efficience(float)= and between 0 -1)
|
|
3226
|
+
|
|
3227
|
+
Retuen:
|
|
3228
|
+
|
|
3229
|
+
Print_time=(float)
|
|
3230
|
+
the time of print in hour
|
|
3231
|
+
|
|
3232
|
+
'''
|
|
3233
|
+
Print_time=float(Volume)/(float(Print_speed)*float(Printer_efficiency))
|
|
3234
|
+
return Print_time
|
|
3235
|
+
|
|
3236
|
+
|
|
3237
|
+
|
|
3238
|
+
|
|
3239
|
+
def Quadratic_Equation(a,b,c):
|
|
3240
|
+
'''
|
|
3241
|
+
This function find "x" in equation ax^2 + bx + c = 0
|
|
3242
|
+
|
|
3243
|
+
Parameters
|
|
3244
|
+
----------
|
|
3245
|
+
a : int
|
|
3246
|
+
known number.
|
|
3247
|
+
b : int
|
|
3248
|
+
known number.
|
|
3249
|
+
c : int
|
|
3250
|
+
known number.
|
|
3251
|
+
|
|
3252
|
+
Returns
|
|
3253
|
+
-------
|
|
3254
|
+
The Quadratic Equation mostly have two answers!
|
|
3255
|
+
x1 ,x2 : int
|
|
3256
|
+
the unknown.
|
|
3257
|
+
|
|
3258
|
+
'''
|
|
3259
|
+
if a==0:
|
|
3260
|
+
print('Error: This is not a quadratic equation')
|
|
3261
|
+
elif ((b**2)-(4*a*c))<0:
|
|
3262
|
+
print("Error:this equation doesn't have an answer")
|
|
3263
|
+
else:
|
|
3264
|
+
x1=(-b+(((b**2)-(4*a*c))**(1/2)))/(2*a)
|
|
3265
|
+
x2=(-b-(((b**2)-(4*a*c))**(1/2)))/(2*a)
|
|
3266
|
+
if x1==x2:
|
|
3267
|
+
return x1
|
|
3268
|
+
else:
|
|
3269
|
+
return x1,x2
|
|
3270
|
+
|
|
3271
|
+
|
|
3272
|
+
|
|
3273
|
+
|
|
3274
|
+
def Rectangle_Area(length,width):
|
|
3275
|
+
'''
|
|
3276
|
+
This function calculate the area of square too!
|
|
3277
|
+
|
|
3278
|
+
Parameters
|
|
3279
|
+
----------
|
|
3280
|
+
length : int
|
|
3281
|
+
length of rectangle.
|
|
3282
|
+
width : int
|
|
3283
|
+
width of rectangle.
|
|
3284
|
+
|
|
3285
|
+
Returns
|
|
3286
|
+
-------
|
|
3287
|
+
rectangle_area: int
|
|
3288
|
+
area of rectangle.
|
|
3289
|
+
|
|
3290
|
+
'''
|
|
3291
|
+
rectangle_area=length*width
|
|
3292
|
+
return rectangle_area
|
|
3293
|
+
|
|
3294
|
+
|
|
3295
|
+
|
|
3296
|
+
|
|
3297
|
+
|
|
3298
|
+
def Rolling_Parameters_Calculator (roller_radius, flow_stress, sample_width,
|
|
3299
|
+
wanted_thickness_reduction, coefficient_of_friction = None) :
|
|
3300
|
+
'''
|
|
3301
|
+
|
|
3302
|
+
|
|
3303
|
+
Parameters
|
|
3304
|
+
----------
|
|
3305
|
+
roller_radius : float
|
|
3306
|
+
roller radius in term of meter.
|
|
3307
|
+
|
|
3308
|
+
flow_stress : float
|
|
3309
|
+
flow stress of your sample in term of Pascal.
|
|
3310
|
+
|
|
3311
|
+
sample_width : float
|
|
3312
|
+
sample width in meter.
|
|
3313
|
+
|
|
3314
|
+
wanted_thickness_reduction : float
|
|
3315
|
+
wanted thickness reduciton (delta h) in terms of meter.
|
|
3316
|
+
|
|
3317
|
+
coefficient_of_friction : floea, optional
|
|
3318
|
+
coefficient of friction between the roller and your sample.
|
|
3319
|
+
notice :
|
|
3320
|
+
|
|
3321
|
+
if you give nothing for friction of coefficeint, function assumed that this
|
|
3322
|
+
coefficient is 0.2 and didnt include the role of friction in the rolling force formula. (* 1.2)
|
|
3323
|
+
but if you enter a value for this, function include the role of friction in the process
|
|
3324
|
+
and multiplies the rolling force by 1.2
|
|
3325
|
+
|
|
3326
|
+
Returns
|
|
3327
|
+
-------
|
|
3328
|
+
delta_h_max : float
|
|
3329
|
+
the maximum thickness reduction that can be reached in terms of meter.
|
|
3330
|
+
|
|
3331
|
+
h_min : float
|
|
3332
|
+
minimum thickness that can be reached in terms of meters.
|
|
3333
|
+
|
|
3334
|
+
rolling_force : float
|
|
3335
|
+
the required force for rolling in terms of Newton.
|
|
3336
|
+
|
|
3337
|
+
|
|
3338
|
+
|
|
3339
|
+
### important : this function give all output in scientific notation.
|
|
3340
|
+
|
|
3341
|
+
'''
|
|
3342
|
+
|
|
3343
|
+
|
|
3344
|
+
|
|
3345
|
+
if coefficient_of_friction == None :
|
|
3346
|
+
|
|
3347
|
+
# calculating delta h max (assumed frcition coefficient 0.2)
|
|
3348
|
+
delta_h_max = "{:e}".format((0.2 ** 2) * roller_radius)
|
|
3349
|
+
|
|
3350
|
+
# calculating h min (assumed friction coefficient 0.2)
|
|
3351
|
+
h_min = "{:e}".format(0.35 * 0.2 * roller_radius * flow_stress)
|
|
3352
|
+
else :
|
|
3353
|
+
|
|
3354
|
+
# calculatin delta h max with given friction coefficient
|
|
3355
|
+
delta_h_max = "{:e}".format((coefficient_of_friction ** 2) * roller_radius)
|
|
3356
|
+
|
|
3357
|
+
# calculaitin h min with given friction coefficeint
|
|
3358
|
+
h_min = "{:e}".format(0.35 * coefficient_of_friction * roller_radius * flow_stress)
|
|
3359
|
+
|
|
3360
|
+
if coefficient_of_friction == None :
|
|
3361
|
+
|
|
3362
|
+
# calculating rolling force (assumed as a ideal process without friction)
|
|
3363
|
+
rolling_force = "{:e}".format(sample_width * flow_stress * (math.sqrt(roller_radius*wanted_thickness_reduction)))
|
|
3364
|
+
else :
|
|
3365
|
+
|
|
3366
|
+
# calculatin rolling force (assumed as a real process with friction)
|
|
3367
|
+
rolling_force = "{:e}".format(sample_width * flow_stress * (math.sqrt(roller_radius*wanted_thickness_reduction)) * 1.2)
|
|
3368
|
+
|
|
3369
|
+
|
|
3370
|
+
return delta_h_max, h_min, rolling_force
|
|
3371
|
+
|
|
3372
|
+
|
|
3373
|
+
|
|
3374
|
+
|
|
3375
|
+
def Rectangle_Perimeter(length,width):
|
|
3376
|
+
'''
|
|
3377
|
+
This function calculate the perimeter of square too!
|
|
3378
|
+
|
|
3379
|
+
Parameters
|
|
3380
|
+
----------
|
|
3381
|
+
length : int
|
|
3382
|
+
length of rectangle.
|
|
3383
|
+
width : int
|
|
3384
|
+
width of rectangle.
|
|
3385
|
+
|
|
3386
|
+
Returns
|
|
3387
|
+
-------
|
|
3388
|
+
rectangle_perimeter: int
|
|
3389
|
+
|
|
3390
|
+
|
|
3391
|
+
'''
|
|
3392
|
+
rectangle_perimeter=2*(length+width)
|
|
3393
|
+
return rectangle_perimeter
|
|
3394
|
+
|
|
3395
|
+
|
|
3396
|
+
|
|
3397
|
+
|
|
3398
|
+
|
|
3399
|
+
def root_degree2(a,b,c):
|
|
3400
|
+
delta=b**2-(4*a*c)
|
|
3401
|
+
|
|
3402
|
+
if delta>0:
|
|
3403
|
+
x=delta*0.5+b/2*a and delta*0.5-b/2*a
|
|
3404
|
+
return x
|
|
3405
|
+
if delta==0:
|
|
3406
|
+
x=-b/2*a
|
|
3407
|
+
return x
|
|
3408
|
+
if delta<0:
|
|
3409
|
+
print("no answer")
|
|
3410
|
+
|
|
3411
|
+
|
|
3412
|
+
|
|
3413
|
+
|
|
3414
|
+
def rayleigh_scattering(intensity, wavelength, particle_size):
|
|
3415
|
+
return intensity - (particle_size / wavelength)**4
|
|
3416
|
+
|
|
3417
|
+
|
|
3418
|
+
|
|
3419
|
+
|
|
3420
|
+
|
|
3421
|
+
|
|
3422
|
+
def rydberg_formula(wavelength, rydberg_constant, principal_quantum_number):
|
|
3423
|
+
return 1 / wavelength - rydberg_constant * principal_quantum_number**2
|
|
3424
|
+
|
|
3425
|
+
|
|
3426
|
+
|
|
3427
|
+
|
|
3428
|
+
def Reynolds_Number_Pipe(d,u,vis,D_H):
|
|
3429
|
+
Re=d*u*D_H/vis
|
|
3430
|
+
return Re
|
|
3431
|
+
|
|
3432
|
+
|
|
3433
|
+
|
|
3434
|
+
|
|
3435
|
+
|
|
3436
|
+
|
|
3437
|
+
def Rejection(CF,CP):
|
|
3438
|
+
'''
|
|
3439
|
+
This function is used for membrane Rejection calculation
|
|
3440
|
+
CF : Pollutant concentration in Feed (g/l)
|
|
3441
|
+
CP : Pollutant concentration in Permeate (g/l)
|
|
3442
|
+
Returns membrane Rejection (%)
|
|
3443
|
+
'''
|
|
3444
|
+
Rej=1-(CP/CF)
|
|
3445
|
+
return Rej
|
|
3446
|
+
|
|
3447
|
+
|
|
3448
|
+
|
|
3449
|
+
|
|
3450
|
+
|
|
3451
|
+
def Shear_Rate(Q,p,r,n):
|
|
3452
|
+
y=(Q/p*r**3)*(3+1/n)
|
|
3453
|
+
return y
|
|
3454
|
+
|
|
3455
|
+
|
|
3456
|
+
|
|
3457
|
+
|
|
3458
|
+
|
|
3459
|
+
def Shear_Stress (F,A):
|
|
3460
|
+
T=F/A
|
|
3461
|
+
return T
|
|
3462
|
+
|
|
3463
|
+
|
|
3464
|
+
|
|
3465
|
+
|
|
3466
|
+
|
|
3467
|
+
def Stress_Intensity_Factor(stress, crack_length, crack_type):
|
|
3468
|
+
'''
|
|
3469
|
+
Calculate the stress intensity factor (K) based on the type of crack.
|
|
3470
|
+
K = crack_type * stress * (sqrt(pi * crack_length))
|
|
3471
|
+
Parameters
|
|
3472
|
+
----------
|
|
3473
|
+
stress : float
|
|
3474
|
+
applied stress (sigma).
|
|
3475
|
+
crack_length : float
|
|
3476
|
+
lenght of the crack (a).
|
|
3477
|
+
crack_type : str
|
|
3478
|
+
there are 3 types of crack 'surface', 'circular', 'internal'.
|
|
3479
|
+
|
|
3480
|
+
Returns: float
|
|
3481
|
+
Stress intensity factor (K).
|
|
3482
|
+
|
|
3483
|
+
'''
|
|
3484
|
+
if crack_type == 'surface': #ضریب شدت تنش سطحی
|
|
3485
|
+
K = 1.12 * stress * (3.1415 ** 0.5) * (crack_length ** 0.5)
|
|
3486
|
+
|
|
3487
|
+
elif crack_type == 'circular': #ضریب شدت تنش برای ترک سکه ای
|
|
3488
|
+
K = (2/3.1415) * stress * (3.1415 ** 0.5) * (crack_length ** 0.5)
|
|
3489
|
+
|
|
3490
|
+
elif crack_type == 'internal': #ضریب شدت تنش برای ترک داخلی
|
|
3491
|
+
K = 1 * stress * (3.1415 ** 0.5) * (crack_length ** 0.5)
|
|
3492
|
+
else:
|
|
3493
|
+
raise ValueError("Invalid crack type. Choose from 'surface', 'circular', or 'internal'.")
|
|
3494
|
+
|
|
3495
|
+
return K
|
|
3496
|
+
|
|
3497
|
+
|
|
3498
|
+
|
|
3499
|
+
|
|
3500
|
+
|
|
3501
|
+
|
|
3502
|
+
def Solidification_Front_Composition (partition_coefficient, alloy_composition, solid_fraction, law_type = 'lever'):
|
|
3503
|
+
'''
|
|
3504
|
+
|
|
3505
|
+
|
|
3506
|
+
Parameters
|
|
3507
|
+
----------
|
|
3508
|
+
partition_coefficient : float
|
|
3509
|
+
a non-dimensional value that describe the scope of liquidus line.
|
|
3510
|
+
|
|
3511
|
+
alloy_composition : float
|
|
3512
|
+
initial composition of your alloy in terms of Wt % of left element in phase diagram.
|
|
3513
|
+
|
|
3514
|
+
solid_fraction : float
|
|
3515
|
+
how much of your alloy solidified.
|
|
3516
|
+
|
|
3517
|
+
law_type : str, optional
|
|
3518
|
+
you can choose two different model for solidification. lever and scheil.
|
|
3519
|
+
The default is 'lever'.
|
|
3520
|
+
|
|
3521
|
+
Returns
|
|
3522
|
+
-------
|
|
3523
|
+
solid_front_massfraction : float
|
|
3524
|
+
solid mass fraction in solidification front in terms of Wt % of left element in phase diagram.
|
|
3525
|
+
|
|
3526
|
+
liquid_front_conc : float
|
|
3527
|
+
liquid mass fraction in solidification front in terms of Wt % of left element in phase diagram .
|
|
3528
|
+
|
|
3529
|
+
|
|
3530
|
+
notice :
|
|
3531
|
+
|
|
3532
|
+
This function round answers to two decimals.
|
|
3533
|
+
'''
|
|
3534
|
+
|
|
3535
|
+
|
|
3536
|
+
|
|
3537
|
+
if law_type.strip().lower() == 'lever' :
|
|
3538
|
+
# calculate base on lever rule
|
|
3539
|
+
|
|
3540
|
+
solid_front_massfraction = round((partition_coefficient * alloy_composition * (1
|
|
3541
|
+
+ (solid_fraction * (partition_coefficient - 1))) ** -1), 2)
|
|
3542
|
+
else :
|
|
3543
|
+
# calculate base on scheil rule
|
|
3544
|
+
|
|
3545
|
+
solid_front_massfraction = round(( partition_coefficient * alloy_composition * (1
|
|
3546
|
+
- solid_fraction) ** (partition_coefficient - 1)), 2)
|
|
3547
|
+
# calcute liquid front mass fraction
|
|
3548
|
+
|
|
3549
|
+
liquid_front_massfraction = round((solid_front_massfraction / partition_coefficient), 2 )
|
|
3550
|
+
|
|
3551
|
+
return solid_front_massfraction, liquid_front_massfraction
|
|
3552
|
+
|
|
3553
|
+
|
|
3554
|
+
|
|
3555
|
+
|
|
3556
|
+
|
|
3557
|
+
|
|
3558
|
+
def Surface_Area_To_Volume_Ratio(Shape,Diameter=0,a=0):
|
|
3559
|
+
"""
|
|
3560
|
+
Calculating the ratio of nanoparticle's surface to its volume by determinig the shape
|
|
3561
|
+
|
|
3562
|
+
Parameters
|
|
3563
|
+
----------
|
|
3564
|
+
Shape:str
|
|
3565
|
+
(sphere,cube or tetrahedron)
|
|
3566
|
+
|
|
3567
|
+
Diameter : int
|
|
3568
|
+
DESCRIPTION. The default is 0.
|
|
3569
|
+
(it is needed for spherical nanoparticles)
|
|
3570
|
+
unit(nm)
|
|
3571
|
+
|
|
3572
|
+
a : int
|
|
3573
|
+
dimention
|
|
3574
|
+
unit(nm)
|
|
3575
|
+
DESCRIPTION. The default is 0.
|
|
3576
|
+
(it is needed for cubic or tetragonal nanoparticles)
|
|
3577
|
+
unit(nm)
|
|
3578
|
+
|
|
3579
|
+
Returns
|
|
3580
|
+
-------
|
|
3581
|
+
Surface_Area_To_Volumr_Ratio : float
|
|
3582
|
+
unit(1/nm)
|
|
3583
|
+
|
|
3584
|
+
"""
|
|
3585
|
+
Shape=input('enter the shape of nanoparticle')
|
|
3586
|
+
if Shape=='sphere':
|
|
3587
|
+
Diameter=int(input('enter the shape of nanoparticles diameter'))
|
|
3588
|
+
Nanoparticle_Surface_Area=math.pi*(Diameter**2)
|
|
3589
|
+
Nanoparticle_Volume=math.pi*((Diameter**3)/6)
|
|
3590
|
+
elif Shape=='cube':
|
|
3591
|
+
a=int(input('enter a '))
|
|
3592
|
+
Nanoparticle_Surface_Area=6*(a**2)
|
|
3593
|
+
Nanoparticle_Volume=a**3
|
|
3594
|
+
elif Shape=='tetrahedron':
|
|
3595
|
+
a=int(input('enter a '))
|
|
3596
|
+
Nanoparticle_Surface_Area=(3**0.5)*(a**2)
|
|
3597
|
+
Nanoparticle_Volume=(2**0.5)*(a**3)/12
|
|
3598
|
+
else:
|
|
3599
|
+
print('please retry and enter the needed parameters corectly')
|
|
3600
|
+
Surface_Area_To_Volume_Ratio=Nanoparticle_Surface_Area/Nanoparticle_Volume
|
|
3601
|
+
print( Surface_Area_To_Volume_Ratio)
|
|
3602
|
+
return Surface_Area_To_Volume_Ratio
|
|
3603
|
+
|
|
3604
|
+
|
|
3605
|
+
|
|
3606
|
+
|
|
3607
|
+
|
|
3608
|
+
def Sphere_Area (R):
|
|
3609
|
+
S = 4 * math.pi * R**2
|
|
3610
|
+
return S
|
|
3611
|
+
|
|
3612
|
+
|
|
3613
|
+
|
|
3614
|
+
def Sphere_Volume(radius):
|
|
3615
|
+
'''
|
|
3616
|
+
|
|
3617
|
+
|
|
3618
|
+
Parameters
|
|
3619
|
+
----------
|
|
3620
|
+
radius : int
|
|
3621
|
+
radius of sphere.
|
|
3622
|
+
|
|
3623
|
+
Returns
|
|
3624
|
+
-------
|
|
3625
|
+
sphere_volume: int
|
|
3626
|
+
volume of sphere.
|
|
3627
|
+
|
|
3628
|
+
'''
|
|
3629
|
+
sphere_volume=(4*(radius**3)*math.pi)/3
|
|
3630
|
+
return sphere_volume
|
|
3631
|
+
|
|
3632
|
+
|
|
3633
|
+
|
|
3634
|
+
|
|
3635
|
+
|
|
3636
|
+
|
|
3637
|
+
|
|
3638
|
+
def Sphere_Surface_Area(radius):
|
|
3639
|
+
'''
|
|
3640
|
+
|
|
3641
|
+
|
|
3642
|
+
Parameters
|
|
3643
|
+
----------
|
|
3644
|
+
radius : int
|
|
3645
|
+
radius of sphere.
|
|
3646
|
+
|
|
3647
|
+
Returns
|
|
3648
|
+
-------
|
|
3649
|
+
sphere_surface_area: int
|
|
3650
|
+
surface area of sphere .
|
|
3651
|
+
|
|
3652
|
+
'''
|
|
3653
|
+
sphere_surface_area=(4*math.pi*(radius**2))
|
|
3654
|
+
return sphere_surface_area
|
|
3655
|
+
|
|
3656
|
+
|
|
3657
|
+
|
|
3658
|
+
|
|
3659
|
+
|
|
3660
|
+
|
|
3661
|
+
def Sample_Size_Calculation(N,e):
|
|
3662
|
+
'''
|
|
3663
|
+
|
|
3664
|
+
This function estimates the number of evaluable subjects required for achieving desired statistical significance for a given hypothesis.
|
|
3665
|
+
|
|
3666
|
+
Parameters
|
|
3667
|
+
----------
|
|
3668
|
+
N : int
|
|
3669
|
+
population of the study
|
|
3670
|
+
e : float
|
|
3671
|
+
margin error
|
|
3672
|
+
|
|
3673
|
+
Returns
|
|
3674
|
+
int
|
|
3675
|
+
Sample_Size_Calculation
|
|
3676
|
+
|
|
3677
|
+
'''
|
|
3678
|
+
return((N)/(1+N)*(e**2))
|
|
3679
|
+
|
|
3680
|
+
|
|
3681
|
+
|
|
3682
|
+
|
|
3683
|
+
|
|
3684
|
+
|
|
3685
|
+
def Stress(strain,young_modulus):
|
|
3686
|
+
'''
|
|
3687
|
+
#The Young's modulus (E) is a property of the material that tells us how easily it can stretch and deform
|
|
3688
|
+
and is defined as the ratio of tensile stress (σ=S) to tensile strain (ε=Ts)
|
|
3689
|
+
|
|
3690
|
+
Parameters
|
|
3691
|
+
----------
|
|
3692
|
+
strain : tensile strain (ε)
|
|
3693
|
+
|
|
3694
|
+
young_modulus : Modulus of Elasticity (N/m2)
|
|
3695
|
+
|
|
3696
|
+
Returns
|
|
3697
|
+
-------
|
|
3698
|
+
S : tensile stress (σ)
|
|
3699
|
+
|
|
3700
|
+
'''
|
|
3701
|
+
|
|
3702
|
+
global S
|
|
3703
|
+
S=strain*young_modulus
|
|
3704
|
+
return S
|
|
3705
|
+
|
|
3706
|
+
|
|
3707
|
+
|
|
3708
|
+
|
|
3709
|
+
|
|
3710
|
+
def Standard_Deviation(a):
|
|
3711
|
+
'''
|
|
3712
|
+
This function calculates the standard deviation of a list of numbers.
|
|
3713
|
+
|
|
3714
|
+
Parameters
|
|
3715
|
+
----------
|
|
3716
|
+
a : list
|
|
3717
|
+
a is a list of numbers.
|
|
3718
|
+
|
|
3719
|
+
Returns
|
|
3720
|
+
-------
|
|
3721
|
+
SD : float
|
|
3722
|
+
SD is the standard deviation of a list of numbers.
|
|
3723
|
+
|
|
3724
|
+
'''
|
|
3725
|
+
E = 0
|
|
3726
|
+
F = 0
|
|
3727
|
+
|
|
3728
|
+
for i in a:
|
|
3729
|
+
E = E + i #sum of numbers
|
|
3730
|
+
M = E / len(a) #Mean
|
|
3731
|
+
|
|
3732
|
+
for i in a:
|
|
3733
|
+
D = (i - M) ** 2
|
|
3734
|
+
F = F + D
|
|
3735
|
+
SD2 = (F / (len(a) - 1))
|
|
3736
|
+
SD = math.sqrt(SD2)
|
|
3737
|
+
return SD
|
|
3738
|
+
|
|
3739
|
+
|
|
3740
|
+
|
|
3741
|
+
|
|
3742
|
+
def Solubility (a,b,c,T, T_unit, T_end):
|
|
3743
|
+
'''
|
|
3744
|
+
Parameters
|
|
3745
|
+
----------
|
|
3746
|
+
a : float
|
|
3747
|
+
Constant.
|
|
3748
|
+
b : float
|
|
3749
|
+
Constant.
|
|
3750
|
+
c : float
|
|
3751
|
+
Constant.
|
|
3752
|
+
T : float
|
|
3753
|
+
Temperature.
|
|
3754
|
+
T_unit:str
|
|
3755
|
+
Unit of temperature.
|
|
3756
|
+
T_end: float
|
|
3757
|
+
Final temperature
|
|
3758
|
+
|
|
3759
|
+
Returns
|
|
3760
|
+
-------
|
|
3761
|
+
Determination solubility at different temperatures upto solubility< 1
|
|
3762
|
+
'''
|
|
3763
|
+
#تبدیل دما به کلوین
|
|
3764
|
+
|
|
3765
|
+
if T_unit=='C':
|
|
3766
|
+
T_unit=T_unit+273.15
|
|
3767
|
+
elif T_unit=='F':
|
|
3768
|
+
T_unit= ((T_unit-32)/1.8)+273.15
|
|
3769
|
+
elif T_unit=='R':
|
|
3770
|
+
T_unit=T_unit*5/9
|
|
3771
|
+
|
|
3772
|
+
# محاسبه حلالیت و توقف محاسبات با رسیدن به غلظت بالاتر از 1
|
|
3773
|
+
|
|
3774
|
+
for T in range (T,T_end):
|
|
3775
|
+
S=a*T**2+b*T+c
|
|
3776
|
+
if S<1:
|
|
3777
|
+
continue
|
|
3778
|
+
else:
|
|
3779
|
+
break
|
|
3780
|
+
return S
|
|
3781
|
+
|
|
3782
|
+
|
|
3783
|
+
|
|
3784
|
+
|
|
3785
|
+
|
|
3786
|
+
|
|
3787
|
+
|
|
3788
|
+
|
|
3789
|
+
def Trapezium_Area(Base1,Base2,Height):
|
|
3790
|
+
|
|
3791
|
+
'''
|
|
3792
|
+
Parameters
|
|
3793
|
+
----------
|
|
3794
|
+
Base1 : int
|
|
3795
|
+
base of trapezium
|
|
3796
|
+
|
|
3797
|
+
Base2 : int
|
|
3798
|
+
base of trapezium
|
|
3799
|
+
|
|
3800
|
+
Height : int
|
|
3801
|
+
height of trapezium
|
|
3802
|
+
|
|
3803
|
+
Returns
|
|
3804
|
+
-------
|
|
3805
|
+
Area : int
|
|
3806
|
+
Area of trapezium
|
|
3807
|
+
'''
|
|
3808
|
+
Area=((Base1+Base2)*Height)/2
|
|
3809
|
+
return Area
|
|
3810
|
+
|
|
3811
|
+
|
|
3812
|
+
|
|
3813
|
+
|
|
3814
|
+
|
|
3815
|
+
def Trapezium_Perimeter(Base1,Base2,Side1,Side2):
|
|
3816
|
+
'''
|
|
3817
|
+
Parameters
|
|
3818
|
+
----------
|
|
3819
|
+
Base1 : int
|
|
3820
|
+
base of trapezium.
|
|
3821
|
+
|
|
3822
|
+
Base2 : int
|
|
3823
|
+
base of trapezium.
|
|
3824
|
+
|
|
3825
|
+
Side1 : int
|
|
3826
|
+
side of trapezium.
|
|
3827
|
+
|
|
3828
|
+
Side2 : int
|
|
3829
|
+
side of trapezium.
|
|
3830
|
+
|
|
3831
|
+
Returns
|
|
3832
|
+
-------
|
|
3833
|
+
Perimeter : int
|
|
3834
|
+
perimeter of trapezium
|
|
3835
|
+
|
|
3836
|
+
'''
|
|
3837
|
+
Perimeter=Base1+Base2+Side1+Side2
|
|
3838
|
+
return Perimeter
|
|
3839
|
+
|
|
3840
|
+
|
|
3841
|
+
|
|
3842
|
+
def Tensile_Strength (f,a):
|
|
3843
|
+
|
|
3844
|
+
'''
|
|
3845
|
+
Parameters
|
|
3846
|
+
----------
|
|
3847
|
+
f : int
|
|
3848
|
+
force required to break
|
|
3849
|
+
|
|
3850
|
+
a : int
|
|
3851
|
+
cross sectional area
|
|
3852
|
+
-------
|
|
3853
|
+
c : int
|
|
3854
|
+
Tensile_Strength
|
|
3855
|
+
'''
|
|
3856
|
+
c=f/a
|
|
3857
|
+
return c
|
|
3858
|
+
|
|
3859
|
+
|
|
3860
|
+
|
|
3861
|
+
|
|
3862
|
+
|
|
3863
|
+
|
|
3864
|
+
|
|
3865
|
+
|
|
3866
|
+
def Triangle_Environment (first_side,second_side,third_side):
|
|
3867
|
+
'''
|
|
3868
|
+
This function gets the perimeter of the triangle
|
|
3869
|
+
|
|
3870
|
+
Parameters
|
|
3871
|
+
----------
|
|
3872
|
+
first_side : float
|
|
3873
|
+
The size of the first side.
|
|
3874
|
+
second_side : float
|
|
3875
|
+
The size of the second side.
|
|
3876
|
+
third_side : float
|
|
3877
|
+
The size of the third side.
|
|
3878
|
+
|
|
3879
|
+
Returns
|
|
3880
|
+
-------
|
|
3881
|
+
Environment : float
|
|
3882
|
+
The output is the perimeter of the triangle.
|
|
3883
|
+
|
|
3884
|
+
'''
|
|
3885
|
+
|
|
3886
|
+
Environment=first_side+second_side+third_side
|
|
3887
|
+
return Environment
|
|
3888
|
+
|
|
3889
|
+
|
|
3890
|
+
|
|
3891
|
+
|
|
3892
|
+
|
|
3893
|
+
|
|
3894
|
+
def Triangle_Area(Height,rule):
|
|
3895
|
+
'''
|
|
3896
|
+
This function obtains the area of the triangle
|
|
3897
|
+
|
|
3898
|
+
Parameters
|
|
3899
|
+
----------
|
|
3900
|
+
Height : float
|
|
3901
|
+
The size of the height of the triangle.
|
|
3902
|
+
rule : float
|
|
3903
|
+
The size of the base of the triangle is.
|
|
3904
|
+
|
|
3905
|
+
Returns
|
|
3906
|
+
-------
|
|
3907
|
+
area : float
|
|
3908
|
+
The output is the area of the triangle.
|
|
3909
|
+
|
|
3910
|
+
'''
|
|
3911
|
+
area=(Height*rule)/2
|
|
3912
|
+
return (area)
|
|
3913
|
+
|
|
3914
|
+
|
|
3915
|
+
|
|
3916
|
+
|
|
3917
|
+
def TB():
|
|
3918
|
+
'''
|
|
3919
|
+
This function is used for bubble temp calculation in mixed solution
|
|
3920
|
+
P : pressure (mmhg)
|
|
3921
|
+
N : number of component
|
|
3922
|
+
Returns bubble temp
|
|
3923
|
+
'''
|
|
3924
|
+
Material=['0=Aceton','1=Acetonitrile','2=Acrylonitrile','3=Ammonia','4=Aniline','5=Benzalehyde','6=Benzene','7=n-Butane','8=n-Butanol','9=iso-Butane','10=iso-Butanol','11=Butylacetate','12=Carbondisulphide','13=Carbontetrachloride','14=Chlorobenzene','15=Chloroform','16=Cyclohexane','17=Cyclohexanol','18=Cyclohexanone','19=Cyclopentane','20=Dioxane','21=Dichloromethane','22=Diethylether','23=Diethylamine','24=Ethanol','25=Ethylacetate','26=Ethylbenzene','27=Ethylamine','28=Formicacid','29=Furfural','30=n-Hexane','31=n-Heptane','32=Methanol','33=Methylacetate','34=Nitrobenzene','35=Nitrogen','36=n-Octane','37=Oxygen','38=Octanol','39=n-Pentane','40=Phenol','41=n-Propanol','42=iso_Propanol','43=Propane','44=Pyridine','45=Styrene','46=Tetrahydrofuran','47=Toluene','48=Trichloroethylene','49=Triethylamine','50=o-Xylene','51=p-Xylene','52=Water']
|
|
3925
|
+
A=[16.39112,16.90395,15.92847,17.51202,16.67784,6.73163,15.9037,15.68151,17.62995,15.77506,18.02933,16.4145,15.77889,15.8434,16.4,16.017,15.7794,19.23534,16.40517,15.8602,17.1151,17.0635,16.5414,15.73382,18.68233,16.35578,16.04305,7.3862,15.9938,15.14517,15.9155,15.877,18.61042,16.58646,16.42172,15.3673,15.9635,15.06244,7.18653,15.8365,15.9614,17.8349,20.4463,15.7277,16.152,15.94618,16.11023,16.00531,15.01158,15.7212,7.00154,6.99052,18.5882]
|
|
3926
|
+
B=[2787.5,3413.1,2782.21,2363.24,3858.22,1369.46,2789.01,2154.9,3367.12,2133.24,3413.34,3293.66,2585.12,2790.78,3485.35,2696.25,2778,5200.53,3677.63,2589.2,3579.78,3053.08,2847.72,2434.73,3667.7,2866.6,3291.66,1137.3,2982.45,2760.09,2738.42,2911.32,3392.57,2839.21,3485.35,648.59,3128.75,674.59,1515.427,2477.07,3183.67,3310.4,4628.95,1872.82,3124.45,3270.26,2768.37,3090.78,2345.48,2674.7,1476.393,1453.43,3984.92]
|
|
3927
|
+
C=[229.67,250.48,222,250.54,200,177.081,220.79,238.74,188.7,245,199.97,210.75,236.46,226.46,224.87,226.24,223.14,251.7,212.7,231.36,240.35,252.6,253,212,226.1,217.9,213.8,235.85,218,162.8,226.2,226.65,230,228,224.84,270.02,209.85,263.07,156.767,233.21,159.5,198.5,252.64,250,212.66,206,226.3,219.14,192.73,205,213.872,215.307,233.43]
|
|
3928
|
+
P=float(input('Pressure='))
|
|
3929
|
+
N=int(input('Number of component='))
|
|
3930
|
+
x=[]
|
|
3931
|
+
T=[]
|
|
3932
|
+
a=[]
|
|
3933
|
+
b=[]
|
|
3934
|
+
c=[]
|
|
3935
|
+
d=len(Material)
|
|
3936
|
+
Index=[]
|
|
3937
|
+
guess=0
|
|
3938
|
+
p=[]
|
|
3939
|
+
U=0
|
|
3940
|
+
|
|
3941
|
+
print(Material)
|
|
3942
|
+
for i in range(0,N):
|
|
3943
|
+
I=[int(input('enter component index='))]
|
|
3944
|
+
Index=Index+I
|
|
3945
|
+
i=0
|
|
3946
|
+
for e in range(0,d):
|
|
3947
|
+
if i==N:
|
|
3948
|
+
break
|
|
3949
|
+
elif Index[i]==e:
|
|
3950
|
+
a=a+[[A[e]]]
|
|
3951
|
+
b=b+[[B[e]]]
|
|
3952
|
+
c=c+[[C[e]]]
|
|
3953
|
+
i=i+1
|
|
3954
|
+
else:
|
|
3955
|
+
e=e+1
|
|
3956
|
+
for i in range(0,N):
|
|
3957
|
+
X=[float(input('enter component mole fraction='))]
|
|
3958
|
+
x=x+X
|
|
3959
|
+
for i in range(0,N):
|
|
3960
|
+
t=[(B[Index[i]]/((A[Index[i]])-math.log(P,math.e))-C[Index[i]])]
|
|
3961
|
+
T=T+t
|
|
3962
|
+
n=0
|
|
3963
|
+
while n<100000:
|
|
3964
|
+
if int(U)==int(P):
|
|
3965
|
+
TBP=guess
|
|
3966
|
+
else:
|
|
3967
|
+
guess=guess+0.01
|
|
3968
|
+
p=[]
|
|
3969
|
+
for i in range(0,N):
|
|
3970
|
+
pr=[math.exp(A[Index[i]]-((B[Index[i]])/((C[Index[i]])+guess)))]
|
|
3971
|
+
p=p+pr
|
|
3972
|
+
U=0
|
|
3973
|
+
for i in range(0,N):
|
|
3974
|
+
u=p[i]*x[i]
|
|
3975
|
+
U=u+U
|
|
3976
|
+
n=n+1
|
|
3977
|
+
return TBP
|
|
3978
|
+
|
|
3979
|
+
|
|
3980
|
+
|
|
3981
|
+
|
|
3982
|
+
|
|
3983
|
+
def TD():
|
|
3984
|
+
'''
|
|
3985
|
+
This function is used for dew temp calculation in mixed solution
|
|
3986
|
+
P : pressure (mmhg)
|
|
3987
|
+
N : number of component
|
|
3988
|
+
Returns bubble temp
|
|
3989
|
+
'''
|
|
3990
|
+
Material=['0=Aceton','1=Acetonitrile','2=Acrylonitrile','3=Ammonia','4=Aniline','5=Benzalehyde','6=Benzene','7=n-Butane','8=n-Butanol','9=iso-Butane','10=iso-Butanol','11=Butylacetate','12=Carbondisulphide','13=Carbontetrachloride','14=Chlorobenzene','15=Chloroform','16=Cyclohexane','17=Cyclohexanol','18=Cyclohexanone','19=Cyclopentane','20=Dioxane','21=Dichloromethane','22=Diethylether','23=Diethylamine','24=Ethanol','25=Ethylacetate','26=Ethylbenzene','27=Ethylamine','28=Formicacid','29=Furfural','30=n-Hexane','31=n-Heptane','32=Methanol','33=Methylacetate','34=Nitrobenzene','35=Nitrogen','36=n-Octane','37=Oxygen','38=Octanol','39=n-Pentane','40=Phenol','41=n-Propanol','42=iso_Propanol','43=Propane','44=Pyridine','45=Styrene','46=Tetrahydrofuran','47=Toluene','48=Trichloroethylene','49=Triethylamine','50=o-Xylene','51=p-Xylene','52=Water']
|
|
3991
|
+
A=[16.39112,16.90395,15.92847,17.51202,16.67784,6.73163,15.9037,15.68151,17.62995,15.77506,18.02933,16.4145,15.77889,15.8434,16.4,16.017,15.7794,19.23534,16.40517,15.8602,17.1151,17.0635,16.5414,15.73382,18.68233,16.35578,16.04305,7.3862,15.9938,15.14517,15.9155,15.877,18.61042,16.58646,16.42172,15.3673,15.9635,15.06244,7.18653,15.8365,15.9614,17.8349,20.4463,15.7277,16.152,15.94618,16.11023,16.00531,15.01158,15.7212,7.00154,6.99052,18.5882]
|
|
3992
|
+
B=[2787.5,3413.1,2782.21,2363.24,3858.22,1369.46,2789.01,2154.9,3367.12,2133.24,3413.34,3293.66,2585.12,2790.78,3485.35,2696.25,2778,5200.53,3677.63,2589.2,3579.78,3053.08,2847.72,2434.73,3667.7,2866.6,3291.66,1137.3,2982.45,2760.09,2738.42,2911.32,3392.57,2839.21,3485.35,648.59,3128.75,674.59,1515.427,2477.07,3183.67,3310.4,4628.95,1872.82,3124.45,3270.26,2768.37,3090.78,2345.48,2674.7,1476.393,1453.43,3984.92]
|
|
3993
|
+
C=[229.67,250.48,222,250.54,200,177.081,220.79,238.74,188.7,245,199.97,210.75,236.46,226.46,224.87,226.24,223.14,251.7,212.7,231.36,240.35,252.6,253,212,226.1,217.9,213.8,235.85,218,162.8,226.2,226.65,230,228,224.84,270.02,209.85,263.07,156.767,233.21,159.5,198.5,252.64,250,212.66,206,226.3,219.14,192.73,205,213.872,215.307,233.43]
|
|
3994
|
+
P=float(input('Pressure='))
|
|
3995
|
+
N=int(input('Number of component='))
|
|
3996
|
+
x=[]
|
|
3997
|
+
T=[]
|
|
3998
|
+
a=[]
|
|
3999
|
+
b=[]
|
|
4000
|
+
c=[]
|
|
4001
|
+
d=len(Material)
|
|
4002
|
+
Index=[]
|
|
4003
|
+
guess=0
|
|
4004
|
+
p=[]
|
|
4005
|
+
U=0.1
|
|
4006
|
+
|
|
4007
|
+
print(Material)
|
|
4008
|
+
for i in range(0,N):
|
|
4009
|
+
I=[int(input('enter component index='))]
|
|
4010
|
+
Index=Index+I
|
|
4011
|
+
i=0
|
|
4012
|
+
for e in range(0,d):
|
|
4013
|
+
if i==N:
|
|
4014
|
+
break
|
|
4015
|
+
elif Index[i]==e:
|
|
4016
|
+
a=a+[[A[e]]]
|
|
4017
|
+
b=b+[[B[e]]]
|
|
4018
|
+
c=c+[[C[e]]]
|
|
4019
|
+
i=i+1
|
|
4020
|
+
else:
|
|
4021
|
+
e=e+1
|
|
4022
|
+
for i in range(0,N):
|
|
4023
|
+
X=[float(input('enter component mole fraction='))]
|
|
4024
|
+
x=x+X
|
|
4025
|
+
for i in range(0,N):
|
|
4026
|
+
t=[(B[Index[i]]/((A[Index[i]])-math.log(P,math.e))-C[Index[i]])]
|
|
4027
|
+
T=T+t
|
|
4028
|
+
n=0
|
|
4029
|
+
while n<100000:
|
|
4030
|
+
if int(1/U)==int(P):
|
|
4031
|
+
TDP=guess
|
|
4032
|
+
else:
|
|
4033
|
+
guess=guess+0.01
|
|
4034
|
+
p=[]
|
|
4035
|
+
for i in range(0,N):
|
|
4036
|
+
pr=[math.exp(A[Index[i]]-((B[Index[i]])/((C[Index[i]])+guess)))]
|
|
4037
|
+
p=p+pr
|
|
4038
|
+
U=0
|
|
4039
|
+
for i in range(0,N):
|
|
4040
|
+
u=x[i]/p[i]
|
|
4041
|
+
U=u+U
|
|
4042
|
+
n=n+1
|
|
4043
|
+
return TDP
|
|
4044
|
+
|
|
4045
|
+
|
|
4046
|
+
|
|
4047
|
+
|
|
4048
|
+
|
|
4049
|
+
|
|
4050
|
+
|
|
4051
|
+
def Tresca_Yield_For_Principal_Stresses(c,hardness,sigma_1,sigma_2,sigma_3,/):
|
|
4052
|
+
'''
|
|
4053
|
+
|
|
4054
|
+
|
|
4055
|
+
Parameters
|
|
4056
|
+
----------
|
|
4057
|
+
c : float
|
|
4058
|
+
C is a coefficient that is between 0.3 and 0.4 depending on the type of material.
|
|
4059
|
+
hardness : float
|
|
4060
|
+
brinell and vickers hardness.
|
|
4061
|
+
sigma_y : float
|
|
4062
|
+
Uniaxial tensile yield strength of material.(Mpa)
|
|
4063
|
+
sigma_1 : float
|
|
4064
|
+
Principal Stresses.
|
|
4065
|
+
sigma_2 : float
|
|
4066
|
+
Principal Stresses.
|
|
4067
|
+
sigma_3 : float
|
|
4068
|
+
Principal Stresses.
|
|
4069
|
+
|
|
4070
|
+
Returns
|
|
4071
|
+
-------
|
|
4072
|
+
Tresca : float
|
|
4073
|
+
Tresca Yield(Mpa)
|
|
4074
|
+
|
|
4075
|
+
'''
|
|
4076
|
+
sigma_y = c*hardness
|
|
4077
|
+
|
|
4078
|
+
Max=max(sigma_1,sigma_2,sigma_3)
|
|
4079
|
+
Min=min(sigma_1,sigma_2,sigma_3)
|
|
4080
|
+
|
|
4081
|
+
Tresca=Max-Min
|
|
4082
|
+
|
|
4083
|
+
if Tresca < sigma_y :
|
|
4084
|
+
print("It is in the elastic area")
|
|
4085
|
+
elif Tresca==sigma_y :
|
|
4086
|
+
print("It is on the verge of plastic deformation")
|
|
4087
|
+
|
|
4088
|
+
elif Tresca > sigma_y :
|
|
4089
|
+
print("Plastic deformation has occurred")
|
|
4090
|
+
|
|
4091
|
+
return Tresca
|
|
4092
|
+
|
|
4093
|
+
|
|
4094
|
+
|
|
4095
|
+
|
|
4096
|
+
|
|
4097
|
+
|
|
4098
|
+
|
|
4099
|
+
def Tresca_Yield_For_Biaxial_Tension(c,hardness,sigma_xx,sigma_yy,tau_xy,/):
|
|
4100
|
+
'''
|
|
4101
|
+
|
|
4102
|
+
|
|
4103
|
+
Parameters
|
|
4104
|
+
----------
|
|
4105
|
+
c : float
|
|
4106
|
+
C is a coefficient that is between 0.3 and 0.4 depending on the type of material.
|
|
4107
|
+
hardness : float
|
|
4108
|
+
brinell and vickers hardness.
|
|
4109
|
+
sigma_y : float
|
|
4110
|
+
Uniaxial tensile yield strength of material.(Mpa)
|
|
4111
|
+
sigma_y : float
|
|
4112
|
+
Uniaxial tensile yield strength of material
|
|
4113
|
+
sigma_xx : float
|
|
4114
|
+
|
|
4115
|
+
sigma_yy : float
|
|
4116
|
+
|
|
4117
|
+
tau_xy : float
|
|
4118
|
+
|
|
4119
|
+
|
|
4120
|
+
Returns
|
|
4121
|
+
-------
|
|
4122
|
+
Tresca : TYPE
|
|
4123
|
+
DESCRIPTION.
|
|
4124
|
+
|
|
4125
|
+
'''
|
|
4126
|
+
|
|
4127
|
+
sigma_y = c*hardness
|
|
4128
|
+
sigma_max=(sigma_xx + sigma_yy)/2 + math.sqrt(((sigma_xx-sigma_yy)/2)**2 + tau_xy**2)
|
|
4129
|
+
sigma_min=(sigma_xx + sigma_yy)/2 - math.sqrt(((sigma_xx-sigma_yy)/2)**2 + tau_xy**2)
|
|
4130
|
+
|
|
4131
|
+
Tresca=sigma_max-sigma_min
|
|
4132
|
+
|
|
4133
|
+
if Tresca < sigma_y :
|
|
4134
|
+
print("It is in the elastic area")
|
|
4135
|
+
elif Tresca==sigma_y :
|
|
4136
|
+
print("It is on the verge of plastic deformation")
|
|
4137
|
+
elif Tresca > sigma_y :
|
|
4138
|
+
print("Deformation is plastic")
|
|
4139
|
+
|
|
4140
|
+
return Tresca
|
|
4141
|
+
|
|
4142
|
+
|
|
4143
|
+
|
|
4144
|
+
|
|
4145
|
+
|
|
4146
|
+
|
|
4147
|
+
def Total_Solidification_Time_of_Casting(volume,surface_area,Cm,n,/):
|
|
4148
|
+
'''
|
|
4149
|
+
|
|
4150
|
+
|
|
4151
|
+
Parameters
|
|
4152
|
+
----------
|
|
4153
|
+
volume : float
|
|
4154
|
+
DESCRIPTION.
|
|
4155
|
+
surface_area : float
|
|
4156
|
+
DESCRIPTION.
|
|
4157
|
+
Cm : float
|
|
4158
|
+
It's amount varies depending on the type of material
|
|
4159
|
+
n : float
|
|
4160
|
+
It's amount varies depending on the type of material but is
|
|
4161
|
+
usually equal to 2
|
|
4162
|
+
|
|
4163
|
+
Returns
|
|
4164
|
+
-------
|
|
4165
|
+
Total_Solidification_Time : float
|
|
4166
|
+
|
|
4167
|
+
'''
|
|
4168
|
+
|
|
4169
|
+
|
|
4170
|
+
Total_Solidification_Time = Cm*((volume/surface_area)**2)
|
|
4171
|
+
return Total_Solidification_Time
|
|
4172
|
+
|
|
4173
|
+
|
|
4174
|
+
|
|
4175
|
+
|
|
4176
|
+
def viscosity (y,T):
|
|
4177
|
+
n=T/y
|
|
4178
|
+
return n
|
|
4179
|
+
|
|
4180
|
+
|
|
4181
|
+
|
|
4182
|
+
|
|
4183
|
+
def Velocity_Equation(V1,V2,a):
|
|
4184
|
+
"""
|
|
4185
|
+
|
|
4186
|
+
|
|
4187
|
+
Parameters
|
|
4188
|
+
----------
|
|
4189
|
+
V1 : float
|
|
4190
|
+
sorat avaliye moteharek.
|
|
4191
|
+
V2 : float
|
|
4192
|
+
sorat nahayi moteharek.
|
|
4193
|
+
a : floar
|
|
4194
|
+
shetab moteharek dar harekat ba shetab sabet.
|
|
4195
|
+
|
|
4196
|
+
Returns mizan jabejayi dar harekat ba shetab sabet
|
|
4197
|
+
-------
|
|
4198
|
+
|
|
4199
|
+
|
|
4200
|
+
"""
|
|
4201
|
+
return (V2**2-V1**2)/2*a
|
|
4202
|
+
|
|
4203
|
+
|
|
4204
|
+
|
|
4205
|
+
|
|
4206
|
+
|
|
4207
|
+
|
|
4208
|
+
def Vicker_Hardness_Calculation (d1,d2,p):
|
|
4209
|
+
|
|
4210
|
+
'''
|
|
4211
|
+
this function is utilized for calculating Vickers hardness.
|
|
4212
|
+
in this method, pyramid shape indentor is used.
|
|
4213
|
+
|
|
4214
|
+
Parameters
|
|
4215
|
+
-----------
|
|
4216
|
+
1. d1: float
|
|
4217
|
+
d1 represents diameter of impress of indentor.
|
|
4218
|
+
|
|
4219
|
+
2. d2 : float
|
|
4220
|
+
d2 represents diameter of impress of indentor
|
|
4221
|
+
|
|
4222
|
+
3. p : int
|
|
4223
|
+
applied load
|
|
4224
|
+
|
|
4225
|
+
Returns --> VHN (Vickers Hardness Number)
|
|
4226
|
+
'''
|
|
4227
|
+
|
|
4228
|
+
d= (d1+d2)/2
|
|
4229
|
+
VHN = (1.854*p)/(d**2)
|
|
4230
|
+
|
|
4231
|
+
return VHN
|
|
4232
|
+
|
|
4233
|
+
|
|
4234
|
+
|
|
4235
|
+
|
|
4236
|
+
|
|
4237
|
+
|
|
4238
|
+
def Voltage_Standing_Wave_Ratio(Vmax,Vmin):
|
|
4239
|
+
'''
|
|
4240
|
+
Parameters
|
|
4241
|
+
----------
|
|
4242
|
+
Vmax: float
|
|
4243
|
+
the highest voltage measured in transition line
|
|
4244
|
+
Vmin: float
|
|
4245
|
+
the lowest voltage measured in transition line
|
|
4246
|
+
Returns
|
|
4247
|
+
-------
|
|
4248
|
+
Row: float
|
|
4249
|
+
its the domain of reflection coefficient of transition line
|
|
4250
|
+
'''
|
|
4251
|
+
s=Vmax/Vmin
|
|
4252
|
+
Row=(s-1)/(s+1)
|
|
4253
|
+
return Row
|
|
4254
|
+
|
|
4255
|
+
|
|
4256
|
+
|
|
4257
|
+
|
|
4258
|
+
def Young_Modulus(stress,strain):
|
|
4259
|
+
E=stress/strain
|
|
4260
|
+
return E
|
|
4261
|
+
|
|
4262
|
+
|
|
4263
|
+
|
|
4264
|
+
|
|
4265
|
+
def youngs_modulus(stress, strain):
|
|
4266
|
+
return stress - strain
|
|
4267
|
+
|
|
4268
|
+
|
|
4269
|
+
|
|
4270
|
+
|
|
4271
|
+
def wavelength_frequency_relation(speed_of_light, wavelength, frequency):
|
|
4272
|
+
return speed_of_light - wavelength * frequency
|
|
4273
|
+
|
|
4274
|
+
|
|
4275
|
+
|
|
4276
|
+
|
|
4277
|
+
|
|
4278
|
+
def Wear_rate(V,F,S):
|
|
4279
|
+
'''
|
|
4280
|
+
Parameters
|
|
4281
|
+
----------
|
|
4282
|
+
V : float
|
|
4283
|
+
lost volume during the wear test in terms of cubic milimeters (mm3)
|
|
4284
|
+
F : float
|
|
4285
|
+
Applied force in terms of newton.
|
|
4286
|
+
S : float
|
|
4287
|
+
Sliding distance in terms of meter.
|
|
4288
|
+
|
|
4289
|
+
Returns
|
|
4290
|
+
-------
|
|
4291
|
+
K : Wear rate
|
|
4292
|
+
This function is for claculation of wear rate if material after wear test. It is in terms of (10-6 mm3/N.m)
|
|
4293
|
+
|
|
4294
|
+
|
|
4295
|
+
'''
|
|
4296
|
+
K=V/(F*S)
|
|
4297
|
+
return K
|
|
4298
|
+
|
|
4299
|
+
|
|
4300
|
+
|
|
4301
|
+
|
|
4302
|
+
|
|
4303
|
+
def Wear_Rate(v, f, s):
|
|
4304
|
+
|
|
4305
|
+
'''
|
|
4306
|
+
this function calculates abrasive wear rate
|
|
4307
|
+
|
|
4308
|
+
Parametrs
|
|
4309
|
+
---------
|
|
4310
|
+
1. v : float ---> (mm3)
|
|
4311
|
+
v represents wear volume
|
|
4312
|
+
|
|
4313
|
+
2. f: int ---> (nm) ---> (N)
|
|
4314
|
+
f represents normal load.
|
|
4315
|
+
|
|
4316
|
+
3. s: float ---> (m)
|
|
4317
|
+
s represents sliding distance.
|
|
4318
|
+
|
|
4319
|
+
Returns --> wear rate (w)
|
|
4320
|
+
|
|
4321
|
+
'''
|
|
4322
|
+
|
|
4323
|
+
w = v/(f*s)
|
|
4324
|
+
|
|
4325
|
+
return w
|
|
4326
|
+
|
|
4327
|
+
|
|
4328
|
+
|
|
4329
|
+
|
|
4330
|
+
|
|
4331
|
+
|
|
4332
|
+
#William, Landel, Ferrry (WLF)
|
|
4333
|
+
def WLF(T,Tg,/):
|
|
4334
|
+
'''
|
|
4335
|
+
The WLF equation is a procedure for shifting data for amorphous polymers obtained at elevated temperatures to a reference temperature.
|
|
4336
|
+
|
|
4337
|
+
Parameters
|
|
4338
|
+
----------
|
|
4339
|
+
T : int or float
|
|
4340
|
+
Temperature, K or degree celsius, Tg<T<Tg+100..
|
|
4341
|
+
Tg : int or float
|
|
4342
|
+
Glass Transition Temperature, K or degree celsius.
|
|
4343
|
+
|
|
4344
|
+
Returns
|
|
4345
|
+
-------
|
|
4346
|
+
aT : int or float
|
|
4347
|
+
shift factor.
|
|
4348
|
+
|
|
4349
|
+
'''
|
|
4350
|
+
b=T-Tg
|
|
4351
|
+
c=-17.44*b
|
|
4352
|
+
d=51.6+b
|
|
4353
|
+
e=c/d
|
|
4354
|
+
aT=math.pow(10,e)
|
|
4355
|
+
return aT
|
|
4356
|
+
|
|
4357
|
+
|
|
4358
|
+
|
|
4359
|
+
def Web_Service_Analyze(services,resp_times,exe_CPU_costs,exe_Mem_costs,exe_Disk_costs,exe_Net_costs):
|
|
4360
|
+
'''
|
|
4361
|
+
|
|
4362
|
+
|
|
4363
|
+
Parameters
|
|
4364
|
+
----------
|
|
4365
|
+
services : list pof str
|
|
4366
|
+
the list of services..
|
|
4367
|
+
resp_times : list of int
|
|
4368
|
+
the list of the responce times of specified web services, measured in millisecond.
|
|
4369
|
+
exe_CPU_costs : list of int
|
|
4370
|
+
list of the percent of execution costs in case
|
|
4371
|
+
of cpu for specified web services.
|
|
4372
|
+
exe_Mem_costs : list of int
|
|
4373
|
+
list of the percent of execution costs in case
|
|
4374
|
+
of memory for specified web services.
|
|
4375
|
+
exe_Disk_costs : list of int
|
|
4376
|
+
list of the percent of execution costs in case
|
|
4377
|
+
of disk for specified web services.
|
|
4378
|
+
exe_Net_costs : list of int
|
|
4379
|
+
list of the percent of execution costs in case
|
|
4380
|
+
of network for specified web services.
|
|
4381
|
+
|
|
4382
|
+
Returns
|
|
4383
|
+
a list of services with their useful information for easily analyze.
|
|
4384
|
+
|
|
4385
|
+
'''
|
|
4386
|
+
web_services_analyze_data=[]
|
|
4387
|
+
for i in range(len(services)):
|
|
4388
|
+
serv_name=services[i]
|
|
4389
|
+
resp_time=resp_times[i]
|
|
4390
|
+
exe_CPU_cost=exe_CPU_costs[i]
|
|
4391
|
+
exe_Mem_cost=exe_Mem_costs[i]
|
|
4392
|
+
exe_Disk_cost=exe_Disk_costs[i]
|
|
4393
|
+
exe_Net_cost=exe_Net_costs[i]
|
|
4394
|
+
|
|
4395
|
+
|
|
4396
|
+
|
|
4397
|
+
if resp_time < 100:
|
|
4398
|
+
resp_time_st='Excellent'
|
|
4399
|
+
elif resp_time >= 100 and resp_time <= 200:
|
|
4400
|
+
resp_time_st='good'
|
|
4401
|
+
elif resp_time > 200 and resp_time <= 1000:
|
|
4402
|
+
resp_time_st='acceptable'
|
|
4403
|
+
elif resp_time > 1000 :
|
|
4404
|
+
resp_time_st='very slow'
|
|
4405
|
+
|
|
4406
|
+
|
|
4407
|
+
if exe_CPU_cost >= 0 and exe_CPU_cost < 30:
|
|
4408
|
+
exe_CPU_cost_st='Low Usage'
|
|
4409
|
+
elif exe_CPU_cost >= 30 and exe_CPU_cost <= 70:
|
|
4410
|
+
exe_CPU_cost_st='Optimal'
|
|
4411
|
+
elif exe_CPU_cost > 70 and exe_CPU_cost <= 85:
|
|
4412
|
+
exe_CPU_cost_st='Moderate Pressure'
|
|
4413
|
+
elif exe_CPU_cost > 85 and exe_CPU_cost <= 100:
|
|
4414
|
+
exe_CPU_cost_st='Critical'
|
|
4415
|
+
|
|
4416
|
+
|
|
4417
|
+
if exe_Mem_cost >= 0 and exe_Mem_cost < 50:
|
|
4418
|
+
exe_Mem_cost_st='Low Usage'
|
|
4419
|
+
elif exe_Mem_cost >= 50 and exe_Mem_cost <= 75:
|
|
4420
|
+
exe_Mem_cost_st='Optimal'
|
|
4421
|
+
elif exe_Mem_cost > 75 and exe_Mem_cost <= 90:
|
|
4422
|
+
exe_Mem_cost_st='Moderate Pressure'
|
|
4423
|
+
elif exe_Mem_cost > 90 and exe_Mem_cost <= 100:
|
|
4424
|
+
exe_Mem_cost_st='Critical'
|
|
4425
|
+
|
|
4426
|
+
|
|
4427
|
+
if exe_Disk_cost >= 0 and exe_Disk_cost < 50:
|
|
4428
|
+
exe_Disk_cost_st='Low Usage'
|
|
4429
|
+
elif exe_Disk_cost >= 50 and exe_Disk_cost <= 75:
|
|
4430
|
+
exe_Disk_cost_st='Optimal'
|
|
4431
|
+
elif exe_Disk_cost > 75 and exe_Disk_cost <= 90:
|
|
4432
|
+
exe_Disk_cost_st='Moderate Pressure'
|
|
4433
|
+
elif exe_Disk_cost > 90 and exe_Disk_cost <= 100:
|
|
4434
|
+
exe_Disk_cost_st='Critical'
|
|
4435
|
+
|
|
4436
|
+
|
|
4437
|
+
if exe_Net_cost >= 0 and exe_Net_cost < 50:
|
|
4438
|
+
exe_Net_cost_st='Low Usage'
|
|
4439
|
+
elif exe_Net_cost >= 50 and exe_Net_cost <= 75:
|
|
4440
|
+
exe_Net_cost_st='Optimal'
|
|
4441
|
+
elif exe_Net_cost > 75 and exe_Net_cost <= 90:
|
|
4442
|
+
exe_Net_cost_st='Moderate Pressure'
|
|
4443
|
+
elif exe_Net_cost > 90 and exe_Net_cost <= 100:
|
|
4444
|
+
exe_Net_cost_st='Critical'
|
|
4445
|
+
|
|
4446
|
+
|
|
4447
|
+
|
|
4448
|
+
web_services_analyze_data.append(('Service Name: '+ serv_name,'Response Time: '+resp_time_st,'CPU Cost: '+ exe_CPU_cost_st,'Memory Cost: '+ exe_Mem_cost_st,'Disk Cost: '+exe_Disk_cost_st,'Network Cost: '+exe_Net_cost_st))
|
|
4449
|
+
|
|
4450
|
+
print(web_services_analyze_data)
|
|
4451
|
+
return (web_services_analyze_data)
|
|
4452
|
+
|
|
4453
|
+
|
|
4454
|
+
|
|
4455
|
+
|
|
4456
|
+
def Welding_Heat_Input(Efficiency,Voltage,Amperage,Speed):
|
|
4457
|
+
'''
|
|
4458
|
+
|
|
4459
|
+
Parameters
|
|
4460
|
+
----------
|
|
4461
|
+
Efficiency : float
|
|
4462
|
+
Efficiency is the proportion of useful inserted heat to the total inserted heat into the weldment.
|
|
4463
|
+
Voltage : float
|
|
4464
|
+
Voltage is the electrical potential of the welding arc (V).
|
|
4465
|
+
Amperage : float
|
|
4466
|
+
Amperage is the amount of electrical current in welding (A).
|
|
4467
|
+
Speed : float
|
|
4468
|
+
Speed is the velocity of the welding tool (cm/min).
|
|
4469
|
+
|
|
4470
|
+
Returns
|
|
4471
|
+
-------
|
|
4472
|
+
Heat_Input is the useful heat inserted into the weldment.
|
|
4473
|
+
|
|
4474
|
+
'''
|
|
4475
|
+
|
|
4476
|
+
Heat_Input=Efficiency*Voltage*Amperage/Speed
|
|
4477
|
+
return Heat_Input
|
|
4478
|
+
|
|
4479
|
+
|
|
4480
|
+
|
|
4481
|
+
|
|
4482
|
+
def Welding_Deposition_Rate(Deposited_Metal_Mass,Welding_Time):
|
|
4483
|
+
'''
|
|
4484
|
+
|
|
4485
|
+
Parameters
|
|
4486
|
+
----------
|
|
4487
|
+
Deposited_Metal_Mass : flaat
|
|
4488
|
+
Deposited_Metal_Mass is the amount of deposited metal during welding (kg).
|
|
4489
|
+
Welding_Time : float
|
|
4490
|
+
Welding_Time is the consumed time for welding (hr).
|
|
4491
|
+
|
|
4492
|
+
Returns
|
|
4493
|
+
-------
|
|
4494
|
+
Deposition_Rate is the amount of deposited metal per hour during the welding operation.
|
|
4495
|
+
|
|
4496
|
+
'''
|
|
4497
|
+
|
|
4498
|
+
Deposition_Rate=Deposited_Metal_Mass/Welding_Time
|
|
4499
|
+
return Deposition_Rate
|
|
4500
|
+
|
|
4501
|
+
|
|
4502
|
+
|
|
4503
|
+
|
|
4504
|
+
|
|
4505
|
+
|
|
4506
|
+
def uncertainty_principle(delta_position, delta_momentum, hbar):
|
|
4507
|
+
return delta_position * delta_momentum - hbar / 2
|