Difference between revisions of "User:Bhamakerti.mohammad"

From ccitonlinewiki
Jump to: navigation, search
(Progress Pekan 2)
(Progress Pekan 2)
Line 54: Line 54:
 
from scipy.optimize import minimize
 
from scipy.optimize import minimize
  
def objective_function(x, density, price_per_unit):
+
def calculate_surface_area(x):
     radius, height, thickness = x
+
     radius, height = x
 
+
     return 2 * np.pi * radius * height + 2 * np.pi * radius**2
     # Calculate the weight of the cylinder (assuming density of aluminium)
 
    inner_radius = radius - thickness
 
    inner_volume = np.pi * inner_radius**2 * height
 
    outer_volume = np.pi * radius**2 * height
 
    shell_volume = outer_volume - inner_volume
 
    weight = shell_volume * density
 
 
 
    # Calculate the cost of the cylinder (based on material price per kg)
 
    cost = weight * price_per_unit
 
 
 
    return cost
 
  
 
def volume_constraint(x, target_volume):
 
def volume_constraint(x, target_volume):
     radius, height, thickness = x
+
     radius, height = x
     volume = np.pi * radius**2 * height * 1000  # Convert to liters
+
     return np.pi * radius**2 * height - target_volume
    return volume - target_volume
 
 
 
def pressure_constraint(x, target_pressure, allowable_stress):
 
    radius, height, thickness = x
 
    inner_radius = radius - thickness
 
    stress = target_pressure * inner_radius / thickness
 
    return allowable_stress - stress
 
 
 
# Target volume in liters
 
target_volume = 1
 
 
 
# Target pressure in bar
 
target_pressure = 8
 
 
 
# Density of aluminium in kg/m^3
 
density_aluminium = 2700
 
 
 
# Allowable stress for aluminium in Pa
 
allowable_stress = 250e6
 
 
 
# Initial guess for radius, height, and thickness
 
x0 = [10.0, 50.0, 1.0]
 
  
# Define the bounds for radius, height, and thickness
+
# Set variabel konstan
bounds = [(0.1, None), (0.1, None), (0.01, None)]
+
target_volume = 1000  # Volume konstan (dalam centimeter kubik)
  
# Define the constraint functions
+
# Definisikan masalah optimisasi
volume_constraint_func = lambda x: volume_constraint(x, target_volume)
+
def optimization_problem(x):
pressure_constraint_func = lambda x: pressure_constraint(x, target_pressure, allowable_stress)
+
    return calculate_surface_area(x), volume_constraint(x, target_volume)
  
# Define the optimization problem
+
# Tetapkan nilai tebakan awal untuk variabel optimisasi
problem = {
+
initial_guess = [1.0, 1.0]
    'fun': objective_function,
 
    'x0': x0,
 
    'bounds': bounds,
 
    'constraints': [{'type': 'eq', 'fun': volume_constraint_func}, {'type': 'ineq', 'fun': pressure_constraint_func}],
 
    'args': (density_aluminium, price_per_unit),
 
    'method': 'SLSQP'
 
}
 
  
# Solve the optimization problem
+
# Definisikan batasan dan batas variabel optimisasi
result = minimize(**problem)
+
constraints = [{'type': 'eq', 'fun': lambda x: optimization_problem(x)[1]}]
 +
bounds = [(0, None), (0, None)]
  
# Extract the optimized dimensions
+
# Lakukan optimisasi
optimal_radius, optimal_height, optimal_thickness = result.x
+
result = minimize(lambda x: optimization_problem(x)[0], initial_guess, method='SLSQP', bounds=bounds, constraints=constraints)
  
# Convert dimensions to mm
+
# Ekstrak variabel hasil yang dioptimalkan
optimal_radius_mm = optimal_radius * 10
+
optimal_radius, optimal_height = result.x
optimal_height_mm = optimal_height * 10
 
optimal_thickness_mm = optimal_thickness * 10
 
  
# Calculate the weight of the cylinder
+
# Hitung luas permukaan yang dioptimalkan
inner_volume = np.pi * (optimal_radius - optimal_thickness)**2 * optimal_height / 1000
+
optimal_surface_area = calculate_surface_area([optimal_radius, optimal_height])
outer_volume = np.pi * optimal_radius**2 * optimal_height / 1000
 
weight = (outer_volume - inner_volume) * density_aluminium
 
  
# Print the optimized results
+
# Tampilkan hasil
print("Optimization Results:")
+
print('Jari-jari Optimal:', optimal_radius, 'cm')
print("Optimal Radius: {:.2f} mm".format(optimal_radius_mm))
+
print('Tinggi Optimal:', optimal_height, 'cm')
print("Optimal Height: {:.2f} mm".format(optimal_height_mm)) }
+
print('Luas Permukaan Optimal:', optimal_surface_area, 'cm^2')
 
</syntaxhighlight>
 
</syntaxhighlight>
  

Revision as of 11:52, 5 June 2023

Introduction

Bhamakerti Mohammad Aydan.jpg

ٱلسَّلَامُ عَلَيْكُمْ وَرَحْمَةُ ٱللَّٰهِ وَبَرَكَاتُهُ

Perkenalkan saya Bhamakerti Mohammad Aydan biasa dipanggil Bhama dengan NPM 2106728023.

Saat ini saya sedang menjalani kelas Metode Numerik 01. Saya berharap bisa terus belajar dengan consciousness yang tinggi.

Progress Pekan 1

Tugas : Optimasi tangki hidrogen dengan kapasitas 1 liter, pressure 8 bar, dan biaya produksi maksimal Rp. 500.000

Pada pekan 1, saya membaca sebuah paper dari Jiai Chen, dkk(2018) dengan judul "Design And Optimization of High-Pressure Hydrogen Cylinders For Intermodal Container Transportation".

Pada paper tersebut, ada beberapa parameter yang mejadi fokus untuk melakukan optimisasi pada desain tabung hydrogen

1. Geometri dari tabung Pada bagian geometri, akan didapatkan nilai outer diameter (2r), length of cylinder (l), dan thickness of cylinder(t)

2. Tekanan Optimal hidrogen Parameter ini dicari untuk menentukan geometri dan ukuran dari tabung

3. Packing Problem Paper ini juga memperhatikan bagaimana mentransport hydrogen seefisien mungkin

Adapun workflow yang digunakan adalah sebagai berikut First, for a single cylinder with the external diameter (2𝑟) and the length of the cylinder body (𝑙), we will search for the optimal hydrogen pressure (Section 3). Second, with a given external diameter (2𝑟) of the cylinders, we will find the optimal body length (𝑙 ) (Section 4). Third, in the cross-section, circle packing problem in a square will be studied and optimal external diameter (2𝑟 ) will be found (Section 5). Finally, combining Sections 3-5, the optimal strategy can be attained.


Progress Pekan 2

Final Report

1) Dimensi optimal Dalam melakukan desain optimasi dari tabung hidrogen, parameter yang pertama diperhitungkan adalah dimensi dari tabung,

Adapun constraintnya adalah : Tekanan 8 bar, volume 1 L, dan harga Rp.500.000

Untuk memperhitungkan optimasi dimensi, saya menggunakan pemrograman melalui kode berikut :

import numpy as np
from scipy.optimize import minimize

def calculate_surface_area(x):
    radius, height = x
    return 2 * np.pi * radius * height + 2 * np.pi * radius**2

def volume_constraint(x, target_volume):
    radius, height = x
    return np.pi * radius**2 * height - target_volume

# Set variabel konstan
target_volume = 1000  # Volume konstan (dalam centimeter kubik)

# Definisikan masalah optimisasi
def optimization_problem(x):
    return calculate_surface_area(x), volume_constraint(x, target_volume)

# Tetapkan nilai tebakan awal untuk variabel optimisasi
initial_guess = [1.0, 1.0]

# Definisikan batasan dan batas variabel optimisasi
constraints = [{'type': 'eq', 'fun': lambda x: optimization_problem(x)[1]}]
bounds = [(0, None), (0, None)]

# Lakukan optimisasi
result = minimize(lambda x: optimization_problem(x)[0], initial_guess, method='SLSQP', bounds=bounds, constraints=constraints)

# Ekstrak variabel hasil yang dioptimalkan
optimal_radius, optimal_height = result.x

# Hitung luas permukaan yang dioptimalkan
optimal_surface_area = calculate_surface_area([optimal_radius, optimal_height])

# Tampilkan hasil
print('Jari-jari Optimal:', optimal_radius, 'cm')
print('Tinggi Optimal:', optimal_height, 'cm')
print('Luas Permukaan Optimal:', optimal_surface_area, 'cm^2')

Sehingga didapatkan hasil

Optimization Results:

Optimal Radius: 100.00 mm

Optimal Height: 500.00 mm