Difference between revisions of "Muhammad Fajri Shiddiq"

From ccitonlinewiki
Jump to: navigation, search
(Review Pertemuan pembelajaran)
Line 38: Line 38:
  
  
'''Python Code'''
 
Storage system design and optimization occurs in several stages, from existing systems to meeting required limits. First, based on the required volume (1 liter), determine the plate size to use, taking into account the minimum plate area using the following calculation:<br>
 
1. Import the math library and the minimize module from scipy.optimize.<br>
 
2. Define the objective(x) function that takes x as an argument, which is an array containing the radius and height. This function calculates the surface area of a cylinder using the given formula.<br>
 
3. Define the constraint(x) function that takes x as an argument, which is an array containing the radius and height. This function calculates the volume of the cylinder and ensures that it is equal to 1000.<br>
 
4. Set the initial_guess for the radius and height.<br>
 
5. Define the bounds for the radius and height. In this case, the radius and height must be non-negative.<br>
 
6. Define the volume constraint (volume_constraint) as an equality (eq) constraint using the constraint function defined earlier.<br>
 
7. Minimize the surface area of the cylinder by calling the minimize function with the objective function, initial_guess, 'SLSQP' method, bounds, and volume_constraint. Save the result in the result variable.<br>
 
8. Retrieve the optimal values for the radius, height, and minimum surface area from the result object.<br>
 
9. Print the results using the print statement, including the optimal radius, optimal height, and minimum surface area.<br>
 
  
import math
+
----
from scipy.optimize import minimize
 
 
def objective(x):
 
    radius, height = x
 
    return 2 * math.pi * radius**2 + 2 * math.pi * radius * height
 
 
def constraint(x):
 
    radius, height = x
 
    return math.pi * radius**2 * height - 1000
 
 
initial_guess = [1, 10]  # Initial guess for the radius and height
 
 
# Define the bounds for the radius and height
 
bounds = [(0, None), (0, None)]
 
 
# Define the volume constraint
 
volume_constraint = {'type': 'eq', 'fun': constraint}
 
 
# Minimize the surface area subject to the volume constraint
 
result = minimize(objective, initial_guess, method='SLSQP', bounds=bounds,                                                                       
 
constraints=volume_constraint)
 
 
optimal_radius = result.x[0]
 
optimal_height = result.x[1]
 
min_surface_area = result.fun
 
 
print(f"\n\nOptimal Radius: {optimal_radius} cm")
 
print(f"Optimal Height: {optimal_height} cm")
 
print(f"Minimum Surface Area: {min_surface_area} cm²\n\n")
 
 
 
  
These calculations yield the following values:<br> 
+
== Final Report ==
● Optimal Radius: 5.419261255088046 cm<br>
 
● Optimal Height: 10.838519182022262 cm<br>
 
● Minimum Surface Area: 553.5810443894838 cm²<br>
 
  
Furthermore, the calculation is performed with a given budget variable, ie Rp. 500,000. Use the following calculations for the calculations:<br>
+
'''Requirements'''
1. Import the `minimize` function from the `scipy.optimize` module.<br>
+
Requirements : Designing hydrogen storage at 8 bar with capacity of 1 liter and budget of Rp 500.000
2. Set the required `price_per_unit` and `capacity_per_unit` variables.<br>
+
Design variables : Geometry size, material thickness to strength, material selection
3. Set the maximum budget (`max_budget`).<br>
+
Constraints : Price not exceeding Rp 500.000
4. Define the objective function (`objective_function`) that takes a variable `x` and returns the negative value of `x` multiplied by `capacity_per_unit`.<br>
+
Objectives : Smallest surface area, thinnest material and withstand 8 bar pressure.
5. Define the budget constraint function (`budget_constraint`) that takes a variable `budget` and returns the difference between `max_budget` and the product of `price_per_unit` and `budget`.<br>
 
6. Create the budget constraint equation (`budget_constraint_eq`) as an inequality constraint using the `ineq` type and the `budget_constraint` function.<br>
 
7. Set the initial value (`x0`) to 0.<br>
 
8. Define the bounds for the optimization problem as a list containing a tuple `(0, None)`.<br>
 
9. Solve the optimization problem using the `minimize` function with the objective function, initial value, 'SLSQP' method, bounds, and constraints.<br>
 
10. Store the solution in the `solution` variable.<br>
 
11. Display the results using the `print` function, including the status of the optimization (whether an optimal cost is found or not), the number of units that can be purchased (`solution.x[0]`), the total storage capacity obtained, and the total budget required.<br>
 
  
from scipy.optimize import minimize
 
  
# Required price and capacity
+
'''Material Selection'''
price_per_unit = 500000  # Rupiah
+
After thorough examination of the available materials for storing hydrogen under pressure, we have opted for '''AISI 316 austenitic stainless steel'''. Our choice is based on the distinct characteristics and benefits provided by this specific material. Below are several factors supporting the consideration of AISI 316 stainless steel for pressurized hydrogen storage:
capacity_per_unit = 1  # Liter
+
a. Corrosion Resistance:
 +
The corrosive nature of hydrogen can weaken materials and pose safety risks by inducing embrittlement and corrosion. AISI 316 stainless steel exhibits exceptional resistance against corrosion, especially in environments where hydrogen concentrations are elevated. This attribute guarantees the enduring robustness and safety of the storage system over an extended period.
  
# Maximum budget
+
b. Compatibility with Hydrogen:
max_budget = 500000
+
Extensive research and real-world applications have shown that AISI 316 stainless steel is highly compatible with hydrogen gas. It exhibits a low permeability to hydrogen, minimizing the chances of hydrogen leakage and ensuring effective confinement within the storage system. This compatibility enables efficient and reliable containment of hydrogen gas.
  
# Objective function
+
c. Strength and Pressure Resistance:
def objective_function(x):
+
In order to endure the internal pressure of pressurized hydrogen storage systems, materials with excellent strength are essential. AISI 316 stainless steel possesses favorable mechanical properties, such as high tensile strength and yield strength, enabling it to withstand the necessary pressure levels without compromising its structural integrity. This quality ensures the material’s ability to withstand the demands of pressurized hydrogen storage effectively.
return -x * capacity_per_unit
 
  
# Budget constraint
+
'''Geometry Optimization'''
def budget_constraint(budget):
 
    return max_budget - (price_per_unit * budget)
 
  
budget_constraint_eq = {'type': 'ineq', 'fun': budget_constraint}
+
'''a. Geometry Constraints'''
 +
Berikut merupakan code optimasi tangki hidrogen dengan kapasitas 1 liter, dengan tekanan 8 Bar, dan biaya produksi maksimal Rp. 500.000 dengan material yang digunakan adalah AISI 316 austenitic stainless steel
  
# Initial value
+
import numpy as np
x0 = 0
+
from scipy.optimize import minimize
  
# Bounds
+
def objektif(x):
bounds = [(0, None)]
+
    # x[0] mewakili jari-jari, x[1] mewakili tinggi
 +
    jari_jari = x[0]
 +
    tinggi = x[1]
  
# Solve the optimization problem
+
    # Hitung luas permukaan struktur silinder
solution = minimize(objective_function, x0, method='SLSQP', bounds=bounds, constraints=[budget_constraint_eq])
+
    luas_permukaan = 2 * np.pi * jari_jari * (jari_jari + tinggi)
  
# Display the results
+
    return luas_permukaan
print("Status:", soluti.success and "Optimal Cost" or "No solution found")
 
print("Number of units that can be purchased:", solution.x[0])
 
print("Total storage capacity obtained:", solution.x[0] * capacity_per_unit, "liters")
 
print("Total budget:", solution.x[0] * price_per_unit, "Rupiah")
 
  
Here are the results I got:<br> 
+
def konstrain(x):
● Status: Optimal Cost<br>
+
    # x[0] mewakili jari-jari, x[1] mewakili tinggi
● Number of units that can be purchased: 1<br>
+
    jari_jari = x[0]
● Total storage capacity obtained: 1.0 liters<br>
+
    tinggi = x[1]
● Total budget: 500000.0 Rupiah<br><br>
 
  
Using the above calculations, we can graph the capacity vs. quantity comparison obtained with the following code: 
+
    # Hitung volume internal struktur silinder
# Chart List
+
    volume = np.pi * jari_jari**2 * tinggi
unit_list = []
 
total_capacity_list = []
 
  
# Calculation of Optimal Solution
+
    # Kembalikan selisih antara volume dan nilai yang diinginkan (1000 cm^3)
for unit_count in range(int(max_budget / price_per_unit) + 1):
+
     return volume - 1000
    total_capacity = unit_count * capacity_per_unit
 
     total_cost = unit_count * price_per_unit
 
  
if total_capacity > optimal_total_capacity and total_cost <= max_budget:
+
# Menebak jari-jari dan tinggi
optimal_unit_count = unit_count
+
x0 = [1.0, 10.0]
    optimal_total_capacity = total_capacity
 
    optimal_total_cost = total_cost
 
  
# Adding data to the list for the chart
+
# Membatasi variabel jari-jari dan tinggi
unit_list.append(unit_count)
+
batas = [(0, None), (0, None)]
total_capacity_list.append(total_capacity)
 
  
# Result Display
+
# Menentukan konstrain dalam bentuk kamus
print("Number of hydrogen storage units to be purchased:", optimal_unit_count)
+
konstrain_dict = {'type': 'eq', 'fun': konstrain}
print("Total storage capacity:", optimal_total_capacity, "liters")
 
print("Total cost:", optimal_total_cost, "Rupiah")
 
  
# Displaying the Chart
+
# Menggunakan fungsi minimize dari scipy untuk optimasi
plt.plot(unit_list, total_capacity_list, color='red')
+
hasil = minimize(objektif, x0, method='SLSQP', bounds=batas, constraints=konstrain_dict)
plt.xlabel('Number of Hydrogen Storage')
 
plt.ylabel('Total Storage Capacity (liters)')
 
plt.title('Hydrogen Storage Optimization')
 
plt.grid(True)
 
plt.show()
 
  
The code used above aims to optimize hydrogen storage given the given capacity and budget constraints. The main goal is to determine the number of hydrogen storage units that should be purchased to achieve maximum storage capacity, taking into account the constraints used.
+
# Mencetak hasil yang telah dioptimasi
 +
print("Hasil Optimisasi:")
 +
print("Jari-jari: {:.2f} cm".format(hasil.x[0]))
 +
print("Tinggi: {:.2f} cm".format(hasil.x[1]))
 +
print("Luas Permukaan: {:.2f} cm^2".format(hasil.fun))
  
Iterations are performed to retrieve data for each unit purchased and capacity and other identified limits. We test each unit quantity to calculate total storage capacity and total associated costs. The iteration stops when the value exceeds the limit. 
+
Pertama mendefinisikan fungsi objektif yang menghitung luas permukaan struktur silinder berdasarkan variabel yang diberikan yakni tinggi dan jari-jari.
[[File:fajri_grafik.png|800x800px]]
+
 
 +
Kemudian mendefinisikan fungsi konstrain yang memastikan volume internal struktur silinder memenuhi konstrain dengan selisih sebesar 1000 cm^3.
 +
 
 +
Berikutnya, menebak tebakan awal untuk jari-jari dan tinggi (x0) serta batasan untuk variabel (batas). Dalam kasus ini, mengasumsikan jari-jari dan tinggi dapat memiliki nilai positif.
 +
 
 +
Selanjutnya, gunakan fungsi minimize dari scipy.optimize untuk menyelesaikan masalah optimisasi. Bemberikan fungsi objektif , metode (SLSQP), tebakan awal, konstrain, dan batasan.
 +
 
 +
Dari code tersebut didapat hasil: '''Tinggi: 10.84 cm, Jari-jari: 5.42 cm Luas Permukaan: 553.58 cm^2'''
 +
 
 +
 
 +
'''b.Material Strenght Constraints'''
 +
Considering the mechanical properties of AISI 316 austenitic stainless steel, it is crucial to adhere to specific limitations to ensure structural integrity.
 +
 
 +
According to the ASME BPV Code Section VIII D.1, the wall thickness of the vessel should not exceed one-fifth of the vessel radius. Additionally, the minimum wall thickness should be at least 1/16 inch (1.59 mm), irrespective of factors such as corrosion allowance, material, or dimensions.
 +
 
 +
 
 +
To account for material strength, we will adopt both a conservative and less conservative approach by using the yield strength and maximum tensile strength as indicators of failure. These values will be employed to establish constraints and ensure that the selected AISI 316 stainless steel material maintains structural stability within acceptable limits.
 +
 
 +
 
 +
In this calculation, we will iterate from a minimum radius of 2.9 mm to 12 mm in increments of 1 mm in each iteration.
 +
 
 +
 
 +
Iteration Process
 +
r = 5.42e-2
 +
p = 800000
 +
t = 2.9e-3
 +
 
 +
while t < 12e-3:
 +
  hoop = (r * p)/(t)
 +
  print('for thickness', t, 'hoop stress =', hoop, "Pa")
 +
  t += 1e-3
 +
  if hoop > 205e9:
 +
    break
 +
 
 +
The above code is for calculating the hoop stress for various thickness values ranging from 2.9 mm to 12 mm, with a constraint that stops the iteration if the total hoop stress exceeds the yield strength of AISI 316 stainless steel. Based on the results, all thickness values ranging from '''2.9 mm to 12 mm''' in 1 mm increments satisfies the yield strength limitation.
 +
 
 +
 
 +
'''Budget Constraint'''
 +
After finding the geometric parameters, the last stage of this optimization is to compare them with the cost limit which cannot exceed IDR 500,000.00. Based on the pre-selected material i.e. AISI 316, we have to choose a tank wall thickness that fits within the budget range. The following is a price list and calculations
 +
 
 +
[[File:foto-budget-constrain-metnum-fajri.jpg]]
 +
 
 +
Berdasarkan tabel diatas, kita dapat menghitung perkiraan harga dengan spesifikasi diatas (luas silinder = 571,88). Dengan membagi Harga dengan luas pelat, maka ditemukan biaya/satuan luas pelat. Setelah dihitung, dengan memaksimalkan budget, minimum berat yang masih masuk akal, dan strength masih wajar, saya memilih ketebalan 6mm untuk tank ini.
 +
 
 +
 
 +
'''Kesimpulan'''
 +
Material yang digunakan : Sheet Metal AISI 316
 +
Tinggi : 10,84 cm
 +
Jari-jari : 5,42 cm
 +
Luas Permukaan :553,58 cm^2
 +
Tebal plat(thickness) : 6 mm
 +
Material Cost : Rp. 181,053,00

Revision as of 08:46, 12 June 2023

Biodata

Nama :

Muhammad Fajri Shiddiq

NPM :

2106727941

TTL :

Palembang, 12 Februari 2004

Program Studi :

Teknik Mesin

Review Pertemuan pembelajaran

Pekan 1 Dalam menjadi manusia dibutuhkan suatu kesadaran akan apapun yang diperbuat. Pada mata kuliah mekanika fluida, proses pembelajaran akan berdasar pada konsep dengan komponen penilaian yang akan dijelaskan lebih lanjut pada Review Pekan 1


Pekan 2 Manometer merupakan alat yang menggunakan kolom cairan untuk mengukur tekanan. Penjelasan lebih lanjut terdapat pada Review pekan 2


Pekan 3 Hasil dari pengamatan penggunaan manometer, terdapat perbedaan tekanan pada pipa ketika salah satu valve dibuka. Kemudian di akhir pekan kelas diadakan kunjungan ke lab agar dapat mengamati secara langsung macam alat pengukuran tekanan, yaitu manometer analog, manometer U, pressure tranducerr. Penjelasan lebih lanjut mengenai pengamatan serta jawaban dari tugas manometer terdapat pada Review pekan 3


Pekan 4 Pembahasan mengenai geometri gerak fluida tanpa adanya perhitungan haya eksternal merupakan pengertian dasar dari kinematika fluida. Aliran sendiri memiliki tipe dan karakteristik yang bermacam. Penjelasan lebih lanjut dan hasil analisis langsung salah satu fenomena aliran pada Rumah Kabeda terdapat pada Review Pekan 4


Pekan 5 Pembahasan mengenai transport reynold, mulai dari pengertian dasar, dan kenapa pada aplikasi kinematika fluida hal ini penting. Penjelasan lebih lanjut terdapat pada Review Pekan 5



Final Report

Requirements Requirements : Designing hydrogen storage at 8 bar with capacity of 1 liter and budget of Rp 500.000 Design variables : Geometry size, material thickness to strength, material selection Constraints : Price not exceeding Rp 500.000 Objectives : Smallest surface area, thinnest material and withstand 8 bar pressure.


Material Selection After thorough examination of the available materials for storing hydrogen under pressure, we have opted for AISI 316 austenitic stainless steel. Our choice is based on the distinct characteristics and benefits provided by this specific material. Below are several factors supporting the consideration of AISI 316 stainless steel for pressurized hydrogen storage: a. Corrosion Resistance: The corrosive nature of hydrogen can weaken materials and pose safety risks by inducing embrittlement and corrosion. AISI 316 stainless steel exhibits exceptional resistance against corrosion, especially in environments where hydrogen concentrations are elevated. This attribute guarantees the enduring robustness and safety of the storage system over an extended period.

b. Compatibility with Hydrogen: Extensive research and real-world applications have shown that AISI 316 stainless steel is highly compatible with hydrogen gas. It exhibits a low permeability to hydrogen, minimizing the chances of hydrogen leakage and ensuring effective confinement within the storage system. This compatibility enables efficient and reliable containment of hydrogen gas.

c. Strength and Pressure Resistance: In order to endure the internal pressure of pressurized hydrogen storage systems, materials with excellent strength are essential. AISI 316 stainless steel possesses favorable mechanical properties, such as high tensile strength and yield strength, enabling it to withstand the necessary pressure levels without compromising its structural integrity. This quality ensures the material’s ability to withstand the demands of pressurized hydrogen storage effectively.

Geometry Optimization

a. Geometry Constraints Berikut merupakan code optimasi tangki hidrogen dengan kapasitas 1 liter, dengan tekanan 8 Bar, dan biaya produksi maksimal Rp. 500.000 dengan material yang digunakan adalah AISI 316 austenitic stainless steel

import numpy as np from scipy.optimize import minimize

def objektif(x):

   # x[0] mewakili jari-jari, x[1] mewakili tinggi
   jari_jari = x[0]
   tinggi = x[1]
   # Hitung luas permukaan struktur silinder
   luas_permukaan = 2 * np.pi * jari_jari * (jari_jari + tinggi)
   return luas_permukaan

def konstrain(x):

   # x[0] mewakili jari-jari, x[1] mewakili tinggi
   jari_jari = x[0]
   tinggi = x[1]
   # Hitung volume internal struktur silinder
   volume = np.pi * jari_jari**2 * tinggi
   # Kembalikan selisih antara volume dan nilai yang diinginkan (1000 cm^3)
   return volume - 1000
  1. Menebak jari-jari dan tinggi

x0 = [1.0, 10.0]

  1. Membatasi variabel jari-jari dan tinggi

batas = [(0, None), (0, None)]

  1. Menentukan konstrain dalam bentuk kamus

konstrain_dict = {'type': 'eq', 'fun': konstrain}

  1. Menggunakan fungsi minimize dari scipy untuk optimasi

hasil = minimize(objektif, x0, method='SLSQP', bounds=batas, constraints=konstrain_dict)

  1. Mencetak hasil yang telah dioptimasi

print("Hasil Optimisasi:") print("Jari-jari: {:.2f} cm".format(hasil.x[0])) print("Tinggi: {:.2f} cm".format(hasil.x[1])) print("Luas Permukaan: {:.2f} cm^2".format(hasil.fun))

Pertama mendefinisikan fungsi objektif yang menghitung luas permukaan struktur silinder berdasarkan variabel yang diberikan yakni tinggi dan jari-jari.

Kemudian mendefinisikan fungsi konstrain yang memastikan volume internal struktur silinder memenuhi konstrain dengan selisih sebesar 1000 cm^3.

Berikutnya, menebak tebakan awal untuk jari-jari dan tinggi (x0) serta batasan untuk variabel (batas). Dalam kasus ini, mengasumsikan jari-jari dan tinggi dapat memiliki nilai positif.

Selanjutnya, gunakan fungsi minimize dari scipy.optimize untuk menyelesaikan masalah optimisasi. Bemberikan fungsi objektif , metode (SLSQP), tebakan awal, konstrain, dan batasan.

Dari code tersebut didapat hasil: Tinggi: 10.84 cm, Jari-jari: 5.42 cm Luas Permukaan: 553.58 cm^2


b.Material Strenght Constraints Considering the mechanical properties of AISI 316 austenitic stainless steel, it is crucial to adhere to specific limitations to ensure structural integrity.

According to the ASME BPV Code Section VIII D.1, the wall thickness of the vessel should not exceed one-fifth of the vessel radius. Additionally, the minimum wall thickness should be at least 1/16 inch (1.59 mm), irrespective of factors such as corrosion allowance, material, or dimensions.


To account for material strength, we will adopt both a conservative and less conservative approach by using the yield strength and maximum tensile strength as indicators of failure. These values will be employed to establish constraints and ensure that the selected AISI 316 stainless steel material maintains structural stability within acceptable limits.


In this calculation, we will iterate from a minimum radius of 2.9 mm to 12 mm in increments of 1 mm in each iteration.


Iteration Process
r = 5.42e-2
p = 800000
t = 2.9e-3
while t < 12e-3:
 hoop = (r * p)/(t)
 print('for thickness', t, 'hoop stress =', hoop, "Pa")
 t += 1e-3
 if hoop > 205e9:
   break

The above code is for calculating the hoop stress for various thickness values ranging from 2.9 mm to 12 mm, with a constraint that stops the iteration if the total hoop stress exceeds the yield strength of AISI 316 stainless steel. Based on the results, all thickness values ranging from 2.9 mm to 12 mm in 1 mm increments satisfies the yield strength limitation.


Budget Constraint After finding the geometric parameters, the last stage of this optimization is to compare them with the cost limit which cannot exceed IDR 500,000.00. Based on the pre-selected material i.e. AISI 316, we have to choose a tank wall thickness that fits within the budget range. The following is a price list and calculations

Foto-budget-constrain-metnum-fajri.jpg

Berdasarkan tabel diatas, kita dapat menghitung perkiraan harga dengan spesifikasi diatas (luas silinder = 571,88). Dengan membagi Harga dengan luas pelat, maka ditemukan biaya/satuan luas pelat. Setelah dihitung, dengan memaksimalkan budget, minimum berat yang masih masuk akal, dan strength masih wajar, saya memilih ketebalan 6mm untuk tank ini.


Kesimpulan Material yang digunakan : Sheet Metal AISI 316 Tinggi : 10,84 cm Jari-jari : 5,42 cm Luas Permukaan :553,58 cm^2 Tebal plat(thickness) : 6 mm Material Cost : Rp. 181,053,00