alterzick commited on
Commit
e623f18
·
verified ·
1 Parent(s): e272289

Add 3 files

Browse files
Files changed (3) hide show
  1. README.md +7 -5
  2. index.html +370 -19
  3. prompts.txt +1 -0
README.md CHANGED
@@ -1,10 +1,12 @@
1
  ---
2
- title: Swab Calculation
3
- emoji: 👁
4
- colorFrom: gray
5
- colorTo: red
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: swab-calculation
3
+ emoji: ⚛️
4
+ colorFrom: pink
5
+ colorTo: blue
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,370 @@
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>SWAB & FFR Calculation Tool</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;500;600;700&display=swap');
12
+ body {
13
+ font-family: 'Poppins', sans-serif;
14
+ }
15
+ .input-group {
16
+ @apply mb-4 flex flex-col;
17
+ }
18
+ .input-group label {
19
+ @apply text-sm font-medium text-gray-700 mb-1;
20
+ }
21
+ .input-group input, .input-group select {
22
+ @apply p-2 border border-gray-300 rounded-md shadow-sm focus:ring-blue-500 focus:border-blue-500;
23
+ }
24
+ .card {
25
+ @apply bg-white p-6 rounded-xl shadow-lg border border-gray-100 transition-all duration-300 hover:shadow-xl;
26
+ }
27
+ .btn {
28
+ @apply px-5 py-2.5 rounded-lg font-medium text-white transition-all duration-200 focus:outline-none focus:ring-2;
29
+ }
30
+ .btn-blue {
31
+ @apply bg-blue-600 hover:bg-blue-700 focus:ring-blue-500;
32
+ }
33
+ .btn-green {
34
+ @apply bg-green-600 hover:bg-green-700 focus:ring-green-500;
35
+ }
36
+ .btn-red {
37
+ @apply bg-red-600 hover:bg-red-700 focus:ring-red-500;
38
+ }
39
+ .table-container {
40
+ @apply mt-6 overflow-x-auto rounded-lg border border-gray-200 shadow;
41
+ }
42
+ table {
43
+ @apply w-full bg-white border-collapse text-sm;
44
+ }
45
+ th, td {
46
+ @apply px-4 py-3 border-b border-gray-200 text-left;
47
+ }
48
+ th {
49
+ @apply bg-gray-50 font-semibold text-gray-700;
50
+ }
51
+ tr:hover {
52
+ @apply bg-blue-50;
53
+ }
54
+ </style>
55
+ </head>
56
+ <body class="bg-gradient-to-br from-blue-50 via-white to-indigo-50 min-h-screen">
57
+
58
+ <div class="container mx-auto px-4 py-8">
59
+ <header class="text-center mb-10">
60
+ <h1 class="text-4xl font-bold text-gray-800 mb-2">
61
+ <i class="fas fa-calculator text-blue-600"></i> SWAB & FFR Calculation System
62
+ </h1>
63
+ <p class="text-gray-600">Analyze fluid levels, load, depth, and production performance</p>
64
+ </header>
65
+
66
+ <div class="grid grid-cols-1 lg:grid-cols-3 gap-8">
67
+
68
+ <!-- Input Panel -->
69
+ <div class="lg:col-span-1">
70
+ <div class="card">
71
+ <h2 class="text-xl font-semibold text-gray-800 mb-5">Input Data</h2>
72
+ <form id="calcForm">
73
+ <div class="input-group">
74
+ <label>Well Name</label>
75
+ <input type="text" id="wellName" required placeholder="e.g. Well-001"/>
76
+ </div>
77
+
78
+ <div class="input-group">
79
+ <label>Fluid Gradient (psi/ft)</label>
80
+ <input type="number" id="fluidGradient" value="0.465" step="0.001" required/>
81
+ </div>
82
+
83
+ <div class="input-group">
84
+ <label>Measured Depth (ft)</label>
85
+ <input type="number" id="measuredDepth" required placeholder="e.g. 8000"/>
86
+ </div>
87
+
88
+ <div class="input-group">
89
+ <label>Fluid Level (ft from surface)</label>
90
+ <input type="number" id="fluidLevel" required placeholder="e.g. 2500"/>
91
+ </div>
92
+
93
+ <div class="input-group">
94
+ <label>API Gravity</label>
95
+ <input type="number" id="apiGravity" step="0.1" required placeholder="e.g. 35.2"/>
96
+ </div>
97
+
98
+ <div class="input-group">
99
+ <label>Production Fluid (BBL/Day)</label>
100
+ <input type="number" id="production" required placeholder="e.g. 420"/>
101
+ </div>
102
+
103
+ <div class="input-group">
104
+ <label>Swab Load (lbs)</label>
105
+ <input type="number" id="swabLoad" required placeholder="e.g. 8500"/>
106
+ </div>
107
+
108
+ <button type="button" onclick="calculate()" class="btn btn-blue w-full mt-2">
109
+ <i class="fas fa-calculator"></i> Calculate
110
+ </button>
111
+ <button type="button" onclick="saveData()" class="btn btn-green w-full mt-2">
112
+ <i class="fas fa-save"></i> Save to Database
113
+ </button>
114
+ </form>
115
+ </div>
116
+ </div>
117
+
118
+ <!-- Results Panel -->
119
+ <div class="lg:col-span-2">
120
+ <div class="grid grid-cols-1 md:grid-cols-2 gap-6 mb-8">
121
+
122
+ <div class="card">
123
+ <h3 class="text-lg font-semibold text-gray-800 mb-3">Key Results</h3>
124
+ <ul class="space-y-2 text-gray-700">
125
+ <li><strong>Static Fluid Level:</strong> <span id="resultStaticLevel">-</span> ft</li>
126
+ <li><strong>Bottom Hole Pressure:</strong> <span id="resultBHP">-</span> psi</li>
127
+ <li><strong>Working Fluid Level:</strong> <span id="resultWorkingFluid">-</span> ft</li>
128
+ <li><strong>Formation Productivity (FFR):</strong> <span id="resultFFR">-</span> BBL/psi</li>
129
+ <li><strong>Fluid Density:</strong> <span id="resultDensity">-</span> lb/ft³</li>
130
+ </ul>
131
+ </div>
132
+
133
+ <div class="card">
134
+ <h3 class="text-lg font-semibold text-gray-800 mb-3">Depth & Load Analysis</h3>
135
+ <ul class="space-y-2 text-gray-700">
136
+ <li><strong>Depth Below Fluid Level:</strong> <span id="resultDepthBelow">-</span> ft</li>
137
+ <li><strong>Pump Depth Utilization:</strong> <span id="resultUtilization">-</span>%</li>
138
+ <li><strong>Hydrostatic Pressure:</strong> <span id="resultHydro">-</span> psi</li>
139
+ <li><strong>Swab Efficiency:</strong> <span id="resultSwabEff">-</span>%</li>
140
+ <li><strong>Load per Barrel:</strong> <span id="resultLoadPerBarrel">-</span> lbs/bbl</li>
141
+ </ul>
142
+ </div>
143
+
144
+ </div>
145
+
146
+ <!-- Visualization -->
147
+ <div class="card">
148
+ <h3 class="text-lg font-semibold text-gray-800 mb-4">Well Profile Visualization</h3>
149
+ <canvas id="wellProfileChart" height="100"></canvas>
150
+ </div>
151
+ </div>
152
+
153
+ </div>
154
+
155
+ <!-- Database Table -->
156
+ <div class="mt-10 card">
157
+ <div class="flex justify-between items-center mb-4">
158
+ <h2 class="text-2xl font-semibold text-gray-800">Database Records</h2>
159
+ <button onclick="clearDatabase()" class="btn btn-red text-sm">
160
+ <i class="fas fa-trash"></i> Clear All
161
+ </button>
162
+ </div>
163
+
164
+ <div class="table-container">
165
+ <table id="dataTable">
166
+ <thead>
167
+ <tr>
168
+ <th>Well</th>
169
+ <th>Fluid Level (ft)</th>
170
+ <th>WFL (ft)</th>
171
+ <th>FFR (BBL/psi)</th>
172
+ <th>Load (lbs)</th>
173
+ <th>Load/BBL</th>
174
+ <th>Depth (ft)</th>
175
+ <th>Date</th>
176
+ <th>Actions</th>
177
+ </tr>
178
+ </thead>
179
+ <tbody>
180
+ <!-- Data will be populated here -->
181
+ </tbody>
182
+ </table>
183
+ </div>
184
+ </div>
185
+
186
+ </div>
187
+
188
+ <script>
189
+ // Initialize local storage
190
+ if (!localStorage.getItem('swabData')) {
191
+ localStorage.setItem('swabData', JSON.stringify([]));
192
+ }
193
+
194
+ // Chart initialization
195
+ let wellChart;
196
+
197
+ window.onload = function() {
198
+ loadDatabase();
199
+ initChart();
200
+ };
201
+
202
+ function initChart() {
203
+ const ctx = document.getElementById('wellProfileChart').getContext('2d');
204
+ wellChart = new Chart(ctx, {
205
+ type: 'bar',
206
+ data: {
207
+ labels: ['Surface', 'Fluid Level', 'Measured Depth'],
208
+ datasets: [{
209
+ label: 'Depth (ft)',
210
+ data: [0, 0, 0],
211
+ backgroundColor: [
212
+ 'rgba(54, 162, 235, 0.6)',
213
+ 'rgba(255, 205, 86, 0.6)',
214
+ 'rgba(75, 192, 192, 0.6)'
215
+ ],
216
+ borderColor: [
217
+ 'rgba(54, 162, 235, 1)',
218
+ 'rgba(255, 205, 86, 1)',
219
+ 'rgba(75, 192, 192, 1)'
220
+ ],
221
+ borderWidth: 1
222
+ }]
223
+ },
224
+ options: {
225
+ scales: {
226
+ y: {
227
+ beginAtZero: true,
228
+ reverse: true,
229
+ title: {
230
+ display: true,
231
+ text: 'Depth from Surface (ft)'
232
+ }
233
+ }
234
+ },
235
+ plugins: {
236
+ legend: {
237
+ display: false
238
+ }
239
+ }
240
+ }
241
+ });
242
+ }
243
+
244
+ function calculate() {
245
+ // Get input values
246
+ const fluidGradient = parseFloat(document.getElementById('fluidGradient').value);
247
+ const measuredDepth = parseFloat(document.getElementById('measuredDepth').value);
248
+ const fluidLevel = parseFloat(document.getElementById('fluidLevel').value);
249
+ const apiGravity = parseFloat(document.getElementById('apiGravity').value);
250
+ const production = parseFloat(document.getElementById('production').value);
251
+ const swabLoad = parseFloat(document.getElementById('swabLoad').value);
252
+
253
+ // Calculations
254
+ const staticFluidLevel = fluidLevel;
255
+ const depthBelowFluid = measuredDepth - fluidLevel;
256
+ const hydrostaticPressure = fluidGradient * depthBelowFluid;
257
+ const bottomHolePressure = fluidGradient * measuredDepth;
258
+ const workingFluidLevel = fluidLevel + (swabLoad / (fluidGradient * 144)); // assuming conversion
259
+ const fluidDensity = 141.5 / (apiGravity + 131.5) * 62.4; // lb/ft³
260
+ const ffr = production / hydrostaticPressure; // Formation Productivity Index
261
+ const pumpUtilization = (fluidLevel / measuredDepth) * 100;
262
+ const swabEfficiency = (workingFluidLevel <= measuredDepth) ? 100 : (measuredDepth / workingFluidLevel) * 100;
263
+ const loadPerBarrel = swabLoad / production;
264
+
265
+ // Display results
266
+ document.getElementById('resultStaticLevel').textContent = staticFluidLevel.toFixed(0);
267
+ document.getElementById('resultBHP').textContent = bottomHolePressure.toFixed(0);
268
+ document.getElementById('resultWorkingFluid').textContent = workingFluidLevel.toFixed(0);
269
+ document.getElementById('resultFFR').textContent = ffr.toFixed(4);
270
+ document.getElementById('resultDensity').textContent = fluidDensity.toFixed(2);
271
+ document.getElementById('resultDepthBelow').textContent = depthBelowFluid.toFixed(0);
272
+ document.getElementById('resultUtilization').textContent = pumpUtilization.toFixed(1);
273
+ document.getElementById('resultHydro').textContent = hydrostaticPressure.toFixed(0);
274
+ document.getElementById('resultSwabEff').textContent = swabEfficiency.toFixed(1);
275
+ document.getElementById('resultLoadPerBarrel').textContent = loadPerBarrel.toFixed(2);
276
+
277
+ // Update chart
278
+ wellChart.data.datasets[0].data = [0, fluidLevel, measuredDepth];
279
+ wellChart.update();
280
+ }
281
+
282
+ function saveData() {
283
+ const wellName = document.getElementById('wellName').value;
284
+ if (!wellName) {
285
+ alert('Please enter a well name');
286
+ return;
287
+ }
288
+
289
+ const data = {
290
+ well: wellName,
291
+ fluidLevel: parseFloat(document.getElementById('fluidLevel').value),
292
+ wfl: parseFloat(document.getElementById('resultWorkingFluid').textContent),
293
+ ffr: parseFloat(document.getElementById('resultFFR').textContent),
294
+ load: parseFloat(document.getElementById('swabLoad').value),
295
+ loadPerBarrel: parseFloat(document.getElementById('resultLoadPerBarrel').textContent),
296
+ depth: parseFloat(document.getElementById('measuredDepth').value),
297
+ timestamp: new Date().toLocaleString()
298
+ };
299
+
300
+ const storedData = JSON.parse(localStorage.getItem('swabData'));
301
+ storedData.push(data);
302
+ localStorage.setItem('swabData', JSON.stringify(storedData));
303
+
304
+ loadDatabase();
305
+ alert(`Data for Well ${wellName} saved successfully!`);
306
+ }
307
+
308
+ function loadDatabase() {
309
+ const tableBody = document.querySelector('#dataTable tbody');
310
+ tableBody.innerHTML = '';
311
+
312
+ const storedData = JSON.parse(localStorage.getItem('swabData'));
313
+
314
+ storedData.forEach((item, index) => {
315
+ const row = document.createElement('tr');
316
+ row.innerHTML = `
317
+ <td class="font-medium">${item.well}</td>
318
+ <td>${item.fluidLevel}</td>
319
+ <td>${item.wfl.toFixed(0)}</td>
320
+ <td>${item.ffr.toFixed(4)}</td>
321
+ <td>${item.load.toLocaleString()}</td>
322
+ <td>${item.loadPerBarrel.toFixed(2)}</td>
323
+ <td>${item.depth}</td>
324
+ <td class="text-sm text-gray-500">${item.timestamp}</td>
325
+ <td>
326
+ <button onclick="loadRecord(${index})" class="text-blue-600 hover:text-blue-800 mr-2" title="Load">
327
+ <i class="fas fa-upload"></i>
328
+ </button>
329
+ <button onclick="deleteRecord(${index})" class="text-red-600 hover:text-red-800" title="Delete">
330
+ <i class="fas fa-trash"></i>
331
+ </button>
332
+ </td>
333
+ `;
334
+ tableBody.appendChild(row);
335
+ });
336
+ }
337
+
338
+ function loadRecord(index) {
339
+ const storedData = JSON.parse(localStorage.getItem('swabData'));
340
+ const data = storedData[index];
341
+
342
+ document.getElementById('wellName').value = data.well;
343
+ document.getElementById('fluidLevel').value = data.fluidLevel;
344
+ document.getElementById('measuredDepth').value = data.depth;
345
+ document.getElementById('swabLoad').value = data.load;
346
+
347
+ // Auto calculate
348
+ calculate();
349
+ alert(`Data for ${data.well} loaded!`);
350
+ }
351
+
352
+ function deleteRecord(index) {
353
+ if (confirm('Are you sure you want to delete this record?')) {
354
+ const storedData = JSON.parse(localStorage.getItem('swabData'));
355
+ storedData.splice(index, 1);
356
+ localStorage.setItem('swabData', JSON.stringify(storedData));
357
+ loadDatabase();
358
+ }
359
+ }
360
+
361
+ function clearDatabase() {
362
+ if (confirm('Are you sure you want to delete ALL records? This cannot be undone.')) {
363
+ localStorage.setItem('swabData', JSON.stringify([]));
364
+ loadDatabase();
365
+ }
366
+ }
367
+ </script>
368
+
369
+ <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/swab-calculation" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
370
+ </html>
prompts.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ buatkan swab calculation and database for ffr , working fluid level , load , depth buy feet and load using bbl