alterzick commited on
Commit
37b98cc
·
verified ·
1 Parent(s): a6e0647

Add 3 files

Browse files
Files changed (3) hide show
  1. README.md +6 -4
  2. index.html +713 -19
  3. prompts.txt +2 -0
README.md CHANGED
@@ -1,10 +1,12 @@
1
  ---
2
- title: Api Pump Design
3
- emoji: 📈
4
- colorFrom: pink
5
  colorTo: green
6
  sdk: static
7
  pinned: false
 
 
8
  ---
9
 
10
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
+ title: api-pump-design
3
+ emoji: ⚛️
4
+ colorFrom: blue
5
  colorTo: green
6
  sdk: static
7
  pinned: false
8
+ tags:
9
+ - QwenSite
10
  ---
11
 
12
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
index.html CHANGED
@@ -1,19 +1,713 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
19
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
6
+ <title>API Pump Design Calculator based on Swab Analysis</title>
7
+ <script src="https://cdn.tailwindcss.com"></script>
8
+ <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
9
+ <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.0/css/all.min.css" rel="stylesheet"/>
10
+ <style>
11
+ @import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');
12
+ body {
13
+ font-family: 'Poppins', sans-serif;
14
+ }
15
+ .card {
16
+ transition: all 0.3s ease;
17
+ }
18
+ .card:hover {
19
+ box-shadow: 0 10px 20px rgba(0,0,0,0.1);
20
+ transform: translateY(-5px);
21
+ }
22
+ .select2-container {
23
+ width: 100% !important;
24
+ }
25
+ .loading {
26
+ border-top-color: #ffffff;
27
+ animation: spin 1s linear infinite;
28
+ }
29
+ .form-group {
30
+ @apply mb-6;
31
+ }
32
+ .form-group label {
33
+ @apply block text-sm font-medium text-gray-700 mb-2;
34
+ }
35
+ .help-text {
36
+ @apply text-xs text-gray-500 mt-1;
37
+ }
38
+ @keyframes spin {
39
+ 0% { transform: rotate(0deg); }
40
+ 100% { transform: rotate(360deg); }
41
+ }
42
+ </style>
43
+ </head>
44
+ <body class="bg-gradient-to-br from-blue-50 to-indigo-100 min-h-screen">
45
+ <div class="container mx-auto px-4 py-8 max-w-6xl">
46
+ <!-- Header -->
47
+ <div class="text-center mb-8">
48
+ <h1 class="text-4xl font-bold text-indigo-800 flex justify-center items-center gap-3">
49
+ <i class="fas fa-cogs text-yellow-500"></i>
50
+ API Pump Design Calculator
51
+ </h1>
52
+ <p class="text-gray-600 mt-2">Based on Swab Analysis & API 11E Standard</p>
53
+ </div>
54
+
55
+ <!-- Main Calculator Card -->
56
+ <div class="bg-white rounded-2xl shadow-xl p-8 mb-6 card">
57
+ <div class="grid grid-cols-1 lg:grid-cols-2 gap-8">
58
+
59
+ <!-- Input Section -->
60
+ <div>
61
+ <h2 class="text-2xl font-semibold text-gray-800 mb-6 flex items-center">
62
+ <i class="fas fa-calculator text-blue-500 mr-2"></i>
63
+ Input Parameters
64
+ </h2>
65
+
66
+ <div class="space-y-6">
67
+ <!-- Depth -->
68
+ <div class="form-group">
69
+ <label for="depth">Well Depth (ft)</label>
70
+ <input type="number" id="depth" placeholder="e.g. 8000"
71
+ class="w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent transition-all">
72
+ <div class="help-text">Measured depth of the well from surface to bottom hole</div>
73
+ </div>
74
+
75
+ <!-- Swab Result -->
76
+ <div class="form-group">
77
+ <label for="swabResult">Swab Result (Barrels per Day - B/D)</label>
78
+ <input type="number" id="swabResult" placeholder="e.g. 500"
79
+ class="w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent transition-all">
80
+ <div class="help-text">Production rate achieved during swabbing operation</div>
81
+ </div>
82
+
83
+ <!-- Fluid Levels -->
84
+ <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
85
+ <div class="form-group">
86
+ <label for="wfl">Working Fluid Level - WFL (ft)</label>
87
+ <input type="number" id="wfl" placeholder="e.g. 6000"
88
+ class="w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent transition-all">
89
+ <div class="help-text">Fluid level during production</div>
90
+ </div>
91
+
92
+ <div class="form-group">
93
+ <label for="sfl">Static Fluid Level - SFL (ft)</label>
94
+ <input type="number" id="sfl" placeholder="e.g. 3000"
95
+ class="w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent transition-all">
96
+ <div class="help-text">Fluid level at static conditions</div>
97
+ </div>
98
+ </div>
99
+
100
+ <!-- Tubing Size -->
101
+ <div class="form-group">
102
+ <label for="tubingSize">Tubing Size (inches)</label>
103
+ <select id="tubingSize" class="w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent transition-all bg-white">
104
+ <option value="">Select Tubing Size</option>
105
+ <option value="1.9">1.900" (40 ft³/1000 ft)</option>
106
+ <option value="2.375">2.375" (60 ft³/1000 ft)</option>
107
+ <option value="2.875">2.875" (80 ft³/1000 ft)</option>
108
+ <option value="3.5">3.500" (120 ft³/1000 ft)</option>
109
+ <option value="4.5">4.500" (180 ft³/1000 ft)</option>
110
+ </select>
111
+ <div class="help-text">Inside diameter of production tubing</div>
112
+ </div>
113
+
114
+ <!-- Casing Size -->
115
+ <div class="form-group">
116
+ <label for="casingSize">Casing Size (inches)</label>
117
+ <select id="casingSize" class="w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent transition-all bg-white">
118
+ <option value="">Select Casing Size</option>
119
+ <option value="4.5">4.500" (Normal)</option>
120
+ <option value="5.5">5.500" (Common)</option>
121
+ <option value="7">7.000" (Large)</option>
122
+ <option value="9.625">9.625" (Surface)</option>
123
+ <option value="13.375">13.375" (Conductor)</option>
124
+ </select>
125
+ <div class="help-text">Inside diameter of the casing string</div>
126
+ </div>
127
+
128
+ <!-- Pump Type -->
129
+ <div class="form-group">
130
+ <label for="pumpType">Pump Type</label>
131
+ <select id="pumpType" class="w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent transition-all bg-white">
132
+ <option value="">Select Pump Type</option>
133
+ <option value="D">Class D - Heavy Duty</option>
134
+ <option value="H">Class H - Heavy Duty</option>
135
+ <option value="K">Class K - Extra Heavy Duty</option>
136
+ </select>
137
+ <div class="help-text">API pump class based on load requirements</div>
138
+ </div>
139
+
140
+ <!-- Power Fluid Specific Gravity -->
141
+ <div class="form-group">
142
+ <label for="specificGravity">Power Fluid Specific Gravity</label>
143
+ <input type="number" step="0.01" id="specificGravity" placeholder="e.g. 0.87" value="0.87"
144
+ class="w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent transition-all">
145
+ <div class="help-text">Typically 0.85-0.90 for crude oil</div>
146
+ </div>
147
+ </div>
148
+ </div>
149
+
150
+ <!-- Output Section -->
151
+ <div>
152
+ <h2 class="text-2xl font-semibold text-gray-800 mb-6 flex items-center">
153
+ <i class="fas fa-chart-line text-green-500 mr-2"></i>
154
+ Design Results
155
+ </h2>
156
+
157
+ <div class="bg-gray-50 rounded-xl p-6 h-full flex flex-col">
158
+ <div id="resultsContainer" class="space-y-4 flex-grow">
159
+ <!-- Enhanced result display with icons -->
160
+ <div class="result-item flex justify-between py-2 border-b border-gray-200">
161
+ <span class="text-gray-600 flex items-center">
162
+ <i class="fas fa-tint mr-2 text-blue-500"></i>
163
+ Recommended Pump Size:
164
+ </span>
165
+ <span id="pumpSize" class="font-semibold text-indigo-700">-</span>
166
+ </div>
167
+ <div class="result-item flex justify-between py-2 border-b border-gray-200">
168
+ <span class="text-gray-600 flex items-center">
169
+ <i class="fas fa-ruler-vertical mr-2 text-green-500"></i>
170
+ Plunger Size (in):
171
+ </span>
172
+ <span id="plungerSize" class="font-semibold text-indigo-700">-</span>
173
+ </div>
174
+ <div class="result-item flex justify-between py-2 border-b border-gray-200">
175
+ <span class="text-gray-600 flex items-center">
176
+ <i class="fas fa-water mr-2 text-purple-500"></i>
177
+ Barrels per Stroke:
178
+ </span>
179
+ <span id="barrelsPerStroke" class="font-semibold text-indigo-700">-</span>
180
+ </div>
181
+ <div class="result-item flex justify-between py-2 border-b border-gray-200">
182
+ <span class="text-gray-600 flex items-center">
183
+ <i class="fas fa-sync-alt mr-2 text-orange-500"></i>
184
+ Required Strokes/min:
185
+ </span>
186
+ <span id="strokesPerMin" class="font-semibold text-indigo-700">-</span>
187
+ </div>
188
+ <div class="result-item flex justify-between py-2 border-b border-gray-200">
189
+ <span class="text-gray-600 flex items-center">
190
+ <i class="fas fa-chart-area mr-2 text-teal-500"></i>
191
+ Fluid Capacity (BPD):
192
+ </span>
193
+ <span id="fluidCapacity" class="font-semibold text-indigo-700">-</span>
194
+ </div>
195
+ <div class="result-item flex justify-between py-2 border-b border-gray-200">
196
+ <span class="text-gray-600 flex items-center">
197
+ <i class="fas fa-compress-arrows-alt mr-2 text-red-500"></i>
198
+ Pump Submergence:
199
+ </span>
200
+ <span id="submergence" class="font-semibold text-indigo-700">-</span>
201
+ </div>
202
+ <div class="result-item flex justify-between py-2 border-b border-gray-200">
203
+ <span class="text-gray-600 flex items-center">
204
+ <i class="fas fa-temperature-low mr-2 text-indigo-500"></i>
205
+ Pump Setting Depth:
206
+ </span>
207
+ <span id="pumpDepth" class="font-semibold text-indigo-700">-</span>
208
+ </div>
209
+ <div class="result-item flex justify-between py-2">
210
+ <span class="text-gray-600 flex items-center">
211
+ <i class="fas fa-file-code mr-2 text-gray-500"></i>
212
+ API Design Code:
213
+ </span>
214
+ <span id="apiCode" class="font-semibold text-indigo-700">-</span>
215
+ </div>
216
+ </div>
217
+
218
+ <div class="mt-6 space-y-4">
219
+ <button id="calculateBtn"
220
+ class="w-full bg-gradient-to-r from-blue-600 to-indigo-600 text-white font-semibold py-3 px-6 rounded-lg hover:from-blue-700 hover:to-indigo-700 transition-all duration-300 flex items-center justify-center">
221
+ <i class="fas fa-cog mr-2"></i>
222
+ Calculate Pump Design
223
+ </button>
224
+
225
+ <button id="resetBtn"
226
+ class="w-full bg-gradient-to-r from-gray-500 to-gray-600 text-white font-semibold py-3 px-6 rounded-lg hover:from-gray-600 hover:to-gray-700 transition-all duration-300 flex items-center justify-center">
227
+ <i class="fas fa-redo mr-2"></i>
228
+ Reset Form
229
+ </button>
230
+ </div>
231
+ </div>
232
+ </div>
233
+ </div>
234
+ </div>
235
+
236
+ <!-- Charts and Analysis Section -->
237
+ <div class="grid grid-cols-1 lg:grid-cols-3 gap-6 mb-6">
238
+ <!-- Performance Chart -->
239
+ <div class="bg-white rounded-2xl shadow-xl p-6 lg:col-span-2">
240
+ <h3 class="text-xl font-semibold text-gray-800 mb-4">Pump Performance Analysis</h3>
241
+ <div class="relative">
242
+ <canvas id="performanceChart" height="300"></canvas>
243
+ <div id="chartLegend" class="absolute top-0 right-0 bg-white p-2 rounded shadow-md text-xs">
244
+ <div class="flex items-center mb-1">
245
+ <div class="w-3 h-3 bg-blue-500 mr-1"></div>
246
+ <span>Max Capacity</span>
247
+ </div>
248
+ <div class="flex items-center">
249
+ <div class="w-3 h-3 bg-green-500 mr-1"></div>
250
+ <span>Required Rate</span>
251
+ </div>
252
+ </div>
253
+ </div>
254
+ </div>
255
+
256
+ <!-- Tubing Capacity Chart -->
257
+ <div class="bg-white rounded-2xl shadow-xl p-6">
258
+ <h3 class="text-xl font-semibold text-gray-800 mb-4">Wellbore Configuration</h3>
259
+ <canvas id="tubingChart" height="300"></canvas>
260
+
261
+ <div class="mt-4 text-sm">
262
+ <div class="flex justify-between mb-2">
263
+ <span class="text-gray-600">Tubing ID:</span>
264
+ <span id="displayTubing" class="font-medium">-</span>
265
+ </div>
266
+ <div class="flex justify-between mb-2">
267
+ <span class="text-gray-600">Casing ID:</span>
268
+ <span id="displayCasing" class="font-medium">-</span>
269
+ </div>
270
+ <div class="flex justify-between">
271
+ <span class="text-gray-600">Annular Volume:</span>
272
+ <span id="annularVol" class="font-medium">-</span>
273
+ </div>
274
+ </div>
275
+ </div>
276
+ </div>
277
+
278
+ <!-- API Standard Reference and Recommendations -->
279
+ <div class="grid grid-cols-1 lg:grid-cols-2 gap-6 mb-6">
280
+ <div class="bg-white rounded-2xl shadow-xl p-6">
281
+ <h3 class="text-xl font-semibold text-gray-800 mb-4 flex items-center">
282
+ <i class="fas fa-lightbulb text-yellow-500 mr-2"></i>
283
+ Design Recommendations
284
+ </h3>
285
+ <div id="recommendations" class="space-y-3 text-gray-700">
286
+ <p>Enter well parameters and click "Calculate" to view design recommendations.</p>
287
+ </div>
288
+ </div>
289
+
290
+ <div class="bg-white rounded-2xl shadow-xl p-6">
291
+ <h3 class="text-xl font-semibold text-gray-800 mb-4 flex items-center">
292
+ <i class="fas fa-book text-purple-500 mr-2"></i>
293
+ API 11E Standard
294
+ </h3>
295
+ <div class="bg-blue-50 border-l-4 border-blue-400 p-4 rounded-r-lg">
296
+ <p class="text-gray-700 text-sm">
297
+ <strong>API Specification 11E</strong> covers design requirements for sucker rod pumping units and accessories.
298
+ This calculator uses standard formulas for pump displacement, fluid load calculations, and proper pump selection
299
+ based on well parameters. Always verify with local engineering standards and manufacturer specifications.
300
+ </p>
301
+ </div>
302
+ </div>
303
+ </div>
304
+ </div>
305
+
306
+ <script>
307
+ // Sample tubing data for chart
308
+ const tubingSizes = ['1.9"', '2.375"', '2.875"', '3.5"', '4.5"'];
309
+ const tubingCapacity = [40, 60, 80, 120, 180]; // ft³ per 1000 ft
310
+
311
+ // Casing data
312
+ const casingSizes = ['4.5"', '5.5"', '7"', '9.625"', '13.375"'];
313
+ const casingCapacity = [50, 80, 150, 280, 500]; // ft³ per 1000 ft
314
+
315
+ // Initialize charts
316
+ let performanceChart, tubingChart;
317
+
318
+ window.onload = function() {
319
+ initCharts();
320
+ setupEventListeners();
321
+ };
322
+
323
+ function initCharts() {
324
+ // Performance Chart
325
+ const perfCtx = document.getElementById('performanceChart').getContext('2d');
326
+ performanceChart = new Chart(perfCtx, {
327
+ type: 'line',
328
+ data: {
329
+ labels: Array.from({length: 21}, (_, i) => i * 2),
330
+ datasets: [{
331
+ label: 'Maximum Capacity (BPD)',
332
+ data: Array.from({length: 21}, () => 0),
333
+ borderColor: '#3B82F6',
334
+ backgroundColor: 'rgba(59, 130, 246, 0.1)',
335
+ tension: 0.3,
336
+ fill: true
337
+ },
338
+ {
339
+ label: 'Required Production Rate',
340
+ data: Array.from({length: 21}, () => 0),
341
+ borderColor: '#10B981',
342
+ borderDash: [5, 5],
343
+ pointRadius: 0
344
+ }]
345
+ },
346
+ options: {
347
+ responsive: true,
348
+ plugins: {
349
+ legend: {
350
+ display: false
351
+ },
352
+ tooltip: {
353
+ mode: 'index',
354
+ intersect: false
355
+ }
356
+ },
357
+ scales: {
358
+ y: {
359
+ beginAtZero: true,
360
+ title: {
361
+ display: true,
362
+ text: 'Capacity (BPD)'
363
+ }
364
+ },
365
+ x: {
366
+ title: {
367
+ display: true,
368
+ text: 'Strokes per Minute'
369
+ },
370
+ ticks: {
371
+ stepSize: 2
372
+ }
373
+ }
374
+ }
375
+ }
376
+ });
377
+
378
+ // Tubing and Casing Chart
379
+ const tubeCtx = document.getElementById('tubingChart').getContext('2d');
380
+ tubingChart = new Chart(tubeCtx, {
381
+ type: 'bar',
382
+ data: {
383
+ labels: ['Tubing', 'Casing'],
384
+ datasets: [{
385
+ label: 'Wellbore Capacity (ft³ per 1000 ft)',
386
+ data: [0, 0],
387
+ backgroundColor: [
388
+ '#8B5CF6', '#4F46E5'
389
+ ],
390
+ borderColor: [
391
+ '#7C3AED', '#4338CA'
392
+ ],
393
+ borderWidth: 1
394
+ }]
395
+ },
396
+ options: {
397
+ responsive: true,
398
+ plugins: {
399
+ legend: {
400
+ display: false
401
+ }
402
+ },
403
+ scales: {
404
+ y: {
405
+ beginAtZero: true,
406
+ title: {
407
+ display: true,
408
+ text: 'Volume (ft³)'
409
+ }
410
+ }
411
+ }
412
+ }
413
+ });
414
+ }
415
+
416
+ function setupEventListeners() {
417
+ document.getElementById('calculateBtn').addEventListener('click', calculateDesign);
418
+ document.getElementById('resetBtn').addEventListener('click', resetForm);
419
+
420
+ // Auto-calculate when pressing Enter in any input field
421
+ document.querySelectorAll('input').forEach(input => {
422
+ input.addEventListener('keypress', function(e) {
423
+ if (e.key === 'Enter') {
424
+ calculateDesign();
425
+ }
426
+ });
427
+ });
428
+
429
+ // Update display when selecting tubing or casing
430
+ document.getElementById('tubingSize').addEventListener('change', updateTubingDisplay);
431
+ document.getElementById('casingSize').addEventListener('change', updateCasingDisplay);
432
+ }
433
+
434
+ function updateTubingDisplay() {
435
+ const tubingSelect = document.getElementById('tubingSize');
436
+ const selectedValue = tubingSelect.value;
437
+ const displayTubing = document.getElementById('displayTubing');
438
+
439
+ if (selectedValue) {
440
+ // Find the corresponding tubing capacity
441
+ const index = ['1.9', '2.375', '2.875', '3.5', '4.5'].indexOf(selectedValue);
442
+ const capacity = index >= 0 ? tubingCapacity[index] : 0;
443
+ displayTubing.textContent = `${selectedValue}" (${capacity} ft³/kft)`;
444
+
445
+ // Update chart
446
+ tubingChart.data.datasets[0].data[0] = capacity;
447
+ tubingChart.update();
448
+ }
449
+ }
450
+
451
+ function updateCasingDisplay() {
452
+ const casingSelect = document.getElementById('casingSize');
453
+ const selectedValue = casingSelect.value;
454
+ const displayCasing = document.getElementById('displayCasing');
455
+
456
+ if (selectedValue) {
457
+ // Find the corresponding casing capacity
458
+ const index = ['4.5', '5.5', '7', '9.625', '13.375'].indexOf(selectedValue);
459
+ const capacity = index >= 0 ? casingCapacity[index] : 0;
460
+ displayCasing.textContent = `${selectedValue}" (${capacity} ft³/kft)`;
461
+
462
+ // Update chart
463
+ tubingChart.data.datasets[0].data[1] = capacity;
464
+ tubingChart.update();
465
+
466
+ // Calculate and display annular volume
467
+ const tubingSelect = document.getElementById('tubingSize');
468
+ const tubingValue = tubingSelect.value;
469
+ if (tubingValue) {
470
+ const tubingIndex = ['1.9', '2.375', '2.875', '3.5', '4.5'].indexOf(tubingValue);
471
+ const tubingCap = tubingIndex >= 0 ? tubingCapacity[tubingIndex] : 0;
472
+
473
+ // Annular volume is the difference between casing and tubing capacity
474
+ const annularVol = capacity - tubingCap;
475
+ document.getElementById('annularVol').textContent = `${annularVol.toFixed(1)} ft³/kft`;
476
+ }
477
+ }
478
+ }
479
+
480
+ function calculateDesign() {
481
+ // Get input values
482
+ const depth = parseFloat(document.getElementById('depth').value);
483
+ const swabResult = parseFloat(document.getElementById('swabResult').value);
484
+ const wfl = parseFloat(document.getElementById('wfl').value);
485
+ const sfl = parseFloat(document.getElementById('sfl').value);
486
+ const tubingSize = document.getElementById('tubingSize').value;
487
+ const casingSize = document.getElementById('casingSize').value;
488
+ const pumpType = document.getElementById('pumpType').value;
489
+ const sg = parseFloat(document.getElementById('specificGravity').value);
490
+
491
+ // Validate inputs
492
+ if (!depth || !swabResult || !wfl || !tubingSize || !casingSize || !pumpType) {
493
+ alert('Please fill in all required fields');
494
+ return;
495
+ }
496
+
497
+ // Validate that WFL is less than depth
498
+ if (wfl >= depth) {
499
+ alert('Working Fluid Level must be less than Well Depth');
500
+ return;
501
+ }
502
+
503
+ // Validate SFL if provided (should be less than or equal to WFL)
504
+ if (sfl && (sfl > wfl || sfl >= depth)) {
505
+ alert('Static Fluid Level must be less than or equal to Working Fluid Level and less than Well Depth');
506
+ return;
507
+ }
508
+
509
+ // Show loading state
510
+ const calcBtn = document.getElementById('calculateBtn');
511
+ const originalText = calcBtn.innerHTML;
512
+ calcBtn.innerHTML = '<i class="fas fa-spinner loading mr-2"></i>Calculating...';
513
+ calcBtn.disabled = true;
514
+
515
+ // Simulate calculation delay
516
+ setTimeout(() => {
517
+ // Calculate pump parameters based on API formulas and rules
518
+ const depthInThousandFt = depth / 1000;
519
+
520
+ // Determine plunger size based on depth and production rate
521
+ let plungerSize, pumpSize;
522
+
523
+ // Decision matrix for pump selection based on depth and production rate
524
+ if (depth < 6000) {
525
+ if (swabResult < 300) {
526
+ plungerSize = "1.25";
527
+ pumpSize = "16";
528
+ } else if (swabResult < 600) {
529
+ plungerSize = "1.5";
530
+ pumpSize = "20";
531
+ } else {
532
+ plungerSize = "1.75";
533
+ pumpSize = "25";
534
+ }
535
+ } else if (depth < 9000) {
536
+ if (swabResult < 400) {
537
+ plungerSize = "1.0";
538
+ pumpSize = "13";
539
+ } else if (swabResult < 700) {
540
+ plungerSize = "1.25";
541
+ pumpSize = "16";
542
+ } else {
543
+ plungerSize = "1.5";
544
+ pumpSize = "20";
545
+ }
546
+ } else {
547
+ if (swabResult < 500) {
548
+ plungerSize = "0.875";
549
+ pumpSize = "10";
550
+ } else if (swabResult < 800) {
551
+ plungerSize = "1.0";
552
+ pumpSize = "13";
553
+ } else {
554
+ plungerSize = "1.25";
555
+ pumpSize = "16";
556
+ }
557
+ }
558
+
559
+ // Calculate barrels per stroke (API formula)
560
+ const barrelsPerStroke = (0.1166 * Math.pow(parseFloat(plungerSize), 2) * depthInThousandFt).toFixed(3);
561
+
562
+ // Calculate required strokes per minute
563
+ const strokesPerMin = (swabResult / (parseFloat(barrelsPerStroke) * 24)).toFixed(2);
564
+
565
+ // Calculate fluid capacity at 15 SPM
566
+ const fluidCapacity = (parseFloat(barrelsPerStroke) * 24 * 15).toFixed(0);
567
+
568
+ // Calculate submergence - more accurate calculation
569
+ const submergence = ((wfl / depth) * 100).toFixed(1) + "%";
570
+
571
+ // Calculate optimal pump setting depth (typically 100-200 ft above fluid level)
572
+ const pumpSettingDepth = wfl + 150; // 150 ft above fluid level
573
+ const maxPumpDepth = depth - 100; // At least 100 ft from bottom
574
+
575
+ const actualPumpDepth = Math.min(pumpSettingDepth, maxPumpDepth);
576
+
577
+ // Generate API code
578
+ const apiCode = `API ${pumpType}-${pumpSize}(${plungerSize}")-${Math.round(depth)}`;
579
+
580
+ // Update results
581
+ document.getElementById('pumpSize').textContent = pumpSize + " Series";
582
+ document.getElementById('plungerSize').textContent = plungerSize + '"';
583
+ document.getElementById('barrelsPerStroke').textContent = barrelsPerStroke + " B/Stroke";
584
+ document.getElementById('strokesPerMin').textContent = strokesPerMin + " SPM";
585
+ document.getElementById('fluidCapacity').textContent = fluidCapacity + " BPD";
586
+ document.getElementById('submergence').textContent = submergence;
587
+ document.getElementById('pumpDepth').textContent = `${Math.round(actualPumpDepth)} ft`;
588
+ document.getElementById('apiCode').textContent = apiCode;
589
+
590
+ // Update charts with relevant data
591
+ updateCharts(parseFloat(strokesPerMin), swabResult, barrelsPerStroke);
592
+
593
+ // Update recommendations
594
+ updateRecommendations(depth, swabResult, wfl, sfl, pumpSize, plungerSize, parseFloat(strokesPerMin), casingSize, tubingSize);
595
+
596
+ // Restore button
597
+ calcBtn.innerHTML = originalText;
598
+ calcBtn.disabled = false;
599
+
600
+ }, 800);
601
+ }
602
+
603
+ function updateCharts(spm, targetProduction, barrelsPerStroke) {
604
+ // Generate performance data based on pump characteristics
605
+ const strokes = Array.from({length: 21}, (_, i) => i * 2);
606
+ const maxCapacity = strokes.map(s => parseFloat(barrelsPerStroke) * s * 24);
607
+
608
+ // Fill the required production rate array
609
+ const requiredRate = Array(21).fill(targetProduction);
610
+
611
+ // Update performance chart
612
+ performanceChart.data.labels = strokes;
613
+ performanceChart.data.datasets[0].data = maxCapacity;
614
+ performanceChart.data.datasets[1].data = requiredRate;
615
+ performanceChart.update();
616
+ }
617
+
618
+ function updateRecommendations(depth, production, wfl, sfl, pumpSize, plungerSize, spm, casing, tubing) {
619
+ const recContainer = document.getElementById('recommendations');
620
+
621
+ // Calculate some key parameters
622
+ const submergence = (wfl / depth) * 100;
623
+ const drawDown = sfl ? sfl - wfl : 0;
624
+
625
+ let recommendations = [];
626
+
627
+ // Pump size recommendation
628
+ recommendations.push(`<strong>Pump Selection:</strong> API Class ${pumpSize} series with ${plungerSize}" plunger is appropriate for your well conditions.`);
629
+
630
+ // Operating range
631
+ if (spm < 6) {
632
+ recommendations.push(`<strong>Low Stroke Speed:</strong> At ${spm} SPM, consider a larger pump or increasing stroke length to improve efficiency.`);
633
+ } else if (spm > 20) {
634
+ recommendations.push(`<strong>High Stroke Speed:</strong> At ${spm} SPM, consider a larger pump or reducing stroke length to minimize wear.`);
635
+ } else {
636
+ recommendations.push(`<strong>Optimal Operation:</strong> At ${spm} SPM, your pump will operate within the recommended range of 6-20 SPM.`);
637
+ }
638
+
639
+ // Submergence analysis
640
+ if (submergence > 85) {
641
+ recommendations.push(`<strong>Deep Submergence:</strong> With ${submergence.toFixed(1)}% submergence, gas interference should be minimal.`);
642
+ } else if (submergence > 60) {
643
+ recommendations.push(`<strong>Moderate Submergence:</strong> At ${submergence.toFixed(1)}% submergence, monitor for potential gas interference.`);
644
+ } else {
645
+ recommendations.push(`<strong>Shallow Submergence:</strong> With only ${submergence.toFixed(1)}% submergence, gas interference is likely. Consider deeper setting or gas separator.`);
646
+ }
647
+
648
+ // Drawdown analysis if SFL is provided
649
+ if (sfl && drawDown > 0) {
650
+ recommendations.push(`<strong>Drawdown Analysis:</strong> The ${drawDown.toFixed(0)} ft drawdown indicates good well productivity.`);
651
+ if (drawDown / depth > 0.2) {
652
+ recommendations.push(`<strong>High Drawdown:</strong> The drawdown represents ${(drawDown/depth*100).toFixed(1)}% of total depth, indicating good reservoir pressure.`);
653
+ }
654
+ }
655
+
656
+ // Casing and tubing compatibility
657
+ const casingVal = parseFloat(casing);
658
+ const tubingVal = parseFloat(tubing);
659
+ if (casingVal - tubingVal < 1) {
660
+ recommendations.push(`<strong>Clearance Check:</strong> With only ${(casingVal-tubingVal).toFixed(2)}" radial clearance, verify all equipment will pass.`);
661
+ }
662
+
663
+ // Generate recommendations HTML
664
+ recContainer.innerHTML = recommendations.map(rec => `<p class="flex items-start"><i class="fas fa-check-circle text-green-500 mr-2 mt-1"></i>${rec}</p>`).join('');
665
+
666
+ // Add a final note
667
+ recContainer.innerHTML += `<p class="text-xs text-gray-500 mt-3">Note: These are general recommendations. Always consult with a pumping unit engineer for final design approval.</p>`;
668
+ }
669
+
670
+ function resetForm() {
671
+ // Reset all form fields
672
+ document.getElementById('depth').value = '';
673
+ document.getElementById('swabResult').value = '';
674
+ document.getElementById('wfl').value = '';
675
+ document.getElementById('sfl').value = '';
676
+ document.getElementById('tubingSize').value = '';
677
+ document.getElementById('casingSize').value = '';
678
+ document.getElementById('pumpType').value = '';
679
+ document.getElementById('specificGravity').value = '0.87';
680
+
681
+ // Reset results
682
+ document.querySelectorAll('#resultsContainer span[id]').forEach(span => {
683
+ span.textContent = '-';
684
+ });
685
+
686
+ // Reset charts
687
+ performanceChart.data.datasets[0].data = Array(21).fill(0);
688
+ performanceChart.data.datasets[1].data = Array(21).fill(0);
689
+ performanceChart.update();
690
+
691
+ tubingChart.data.datasets[0].data = [0, 0];
692
+ tubingChart.update();
693
+
694
+ // Reset displays
695
+ document.getElementById('displayTubing').textContent = '-';
696
+ document.getElementById('displayCasing').textContent = '-';
697
+ document.getElementById('annularVol').textContent = '-';
698
+
699
+ // Reset recommendations
700
+ document.getElementById('recommendations').innerHTML = '<p class="text-gray-700">Enter well parameters and click "Calculate" to view design recommendations.</p>';
701
+ }
702
+
703
+ // Add some sample data to inputs for easier testing
704
+ document.getElementById('depth').value = '8500';
705
+ document.getElementById('swabResult').value = '650';
706
+ document.getElementById('wfl').value = '6700';
707
+ document.getElementById('sfl').value = '4500';
708
+ document.getElementById('tubingSize').value = '2.875';
709
+ document.getElementById('casingSize').value = '5.5';
710
+ document.getElementById('pumpType').value = 'D';
711
+ </script>
712
+ <p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-qwensite.hf.space/logo.svg" alt="qwensite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-qwensite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >QwenSite</a> - 🧬 <a href="https://enzostvs-qwensite.hf.space?remix=alterzick/api-pump-design" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
713
+ </html>
prompts.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ tolong buatkan aplikasi perhitungan design pompa berdasarkan hasil swab dengan standard api , dengan pemilihan tubing drop down list kecuali kedalaman dan angkatan satuan barrel dan waktu jika memungkinkan semua auto atau dropdownlist
2
+ tambahkan pemilihan jenis casing dengan drop downlist , dan untuk swab result perbaiki satuannya , untuk wfl dan sfl tambahkan