root commited on
Commit
9ab91ac
·
1 Parent(s): 661b835
Files changed (7) hide show
  1. CAL.py +0 -130
  2. ELEMENT.txt +0 -0
  3. NODE.txt +0 -0
  4. U.txt +0 -0
  5. __pycache__/CAL_IA.cpython-312.pyc +0 -0
  6. app.py +5 -3
  7. config.yaml +5 -0
CAL.py DELETED
@@ -1,130 +0,0 @@
1
- import numpy as np
2
- import matplotlib.pyplot as plt
3
- import plotly.graph_objects as go
4
-
5
- from assemble import assemblage,nodes,elements
6
-
7
- #Paramètres généraux de la simulation
8
-
9
- E=210_000
10
- NU=.3
11
- C=E/((1+NU)*(1-2*NU))*np.array([
12
- [(1-NU), NU, 0],
13
- [NU,(1-NU), 0],
14
- [0, 0,(1-2*NU)/2]]
15
- )
16
- K=assemblage()
17
- F=np.zeros_like(K[0,:])
18
- print(F.shape)
19
-
20
-
21
- Kreack=K.copy()
22
-
23
- Freac=F.copy()
24
- P=np.max(np.max(K))*10
25
- for i in range(nodes.shape[0]):
26
- if nodes[i,1]==12.5 and nodes[i,2]==13.75:
27
- ind0=(i-1)*2+0
28
- ind1=(i-1)*2+1
29
- K[ind0,ind0]+=P
30
- K[ind1,ind1]+=P
31
- F[ind0]+=1000
32
- if nodes[i,1]==12.5 and nodes[i,2]==-13.75:
33
- ind0=(i-1)*2+0
34
- ind1=(i-1)*2+1
35
- K[ind0,ind0]+=P
36
- K[ind1,ind1]+=P
37
- F[ind0]-=1000
38
-
39
-
40
-
41
- U=np.linalg.solve(K,F)
42
- Depl = np.zeros_like(nodes)
43
- Depl[:, 0] = U[0::2]
44
- np.savetxt("U.txt",U)
45
- # en x
46
- Depl[:, 1] = U[1::2]
47
-
48
- # en y
49
-
50
- # amplification = 10
51
- # nodes_def = nodes + amplification * Depl
52
-
53
- # # nœuds déplacés amplifiés
54
-
55
- # plt.figure()
56
-
57
- # # Choix des couleurs : ici on colorie selon la norme du déplacement (valeur scalaire par nœud)
58
- # disp_norm = np.linalg.norm(Depl, axis=1)
59
-
60
- # plt.tripcolor(nodes_def[:, 0], nodes_def[:, 1], elements - 1, disp_norm, edgecolors='k', cmap='jet')
61
-
62
- # plt.colorbar(label='Norme du déplacement')
63
- # plt.title('Maillage déformé coloré selon déplacement')
64
- # plt.xlabel('X (mm)')
65
- # plt.ylabel('Y (mm)')
66
- # plt.axis('equal')
67
- # plt.grid(True)
68
- # plt.show()
69
- # # plt.savefig("CT/results/maillage_def.png")
70
-
71
-
72
-
73
-
74
-
75
-
76
- # # Supposons que tu as déjà :
77
- # # nodes : (n_noeuds, 2), coordonnées XY, indices 0-based
78
- # # elements : (n_elem, 3), indices de nœuds, indices 0-based
79
-
80
- # # Si tes éléments sont 1-based, convertis :
81
- # # elements = elements - 1
82
-
83
- # # Liste des faces pour Plotly
84
- # I = elements[:, 0]
85
- # J = elements[:, 1]
86
- # K = elements[:, 2]
87
-
88
- # fig = go.Figure()
89
-
90
- # # Maillage triangulaire
91
- # fig.add_trace(go.Mesh3d(
92
- # x=nodes[:, 0], y=nodes[:, 1], z=np.zeros(nodes.shape[0]),
93
- # i=I, j=J, k=K,
94
- # color='lightblue',
95
- # opacity=0.4,
96
- # flatshading=True,
97
- # name="Maillage",
98
- # showscale=False,
99
- # hoverinfo='skip'
100
-
101
- # # Pour éviter duplication de survol
102
- # ))
103
-
104
- # # Points des nœuds + leur numéro au survol
105
- # fig.add_trace(go.Scatter3d(
106
- # x=nodes[:,0]+Depl[:,0], y=nodes[:,1]+Depl[:,1], z=np.zeros(nodes.shape[0]),
107
- # mode='markers+text',
108
- # # text=[str(i+1) for i in range(nodes.shape[0])],
109
-
110
- # # Numéro affiché
111
- # textposition='top center',
112
- # marker=dict(size=4, color='red'),
113
- # # hovertemplate=
114
- # # 'Noeud %{text} <br>X: %{x:.2f}<br>Y: %{y:.2f}<extra></extra>',
115
- # showlegend=False,
116
- # ))
117
-
118
- # fig.update_layout(
119
- # scene=dict(
120
- # xaxis_title='X',
121
- # yaxis_title='Y',
122
- # zaxis_title='',
123
- # aspectmode='data'
124
- # ),
125
- # title="Maillage FEM interactif (collaborez, zoomez, survolez!)",
126
- # margin=dict(l=0, r=0, t=40, b=0),
127
- # height=600,
128
- # )
129
-
130
- # fig.show()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ELEMENT.txt ADDED
The diff for this file is too large to render. See raw diff
 
NODE.txt ADDED
The diff for this file is too large to render. See raw diff
 
U.txt ADDED
The diff for this file is too large to render. See raw diff
 
__pycache__/CAL_IA.cpython-312.pyc ADDED
Binary file (5.46 kB). View file
 
app.py CHANGED
@@ -1,7 +1,8 @@
1
  import numpy as np
2
  import streamlit as st
3
  import plotly.graph_objects as go
4
- import CAL
 
5
 
6
  st.set_page_config(page_title="Maillage FEM interactif", layout="wide")
7
 
@@ -49,7 +50,7 @@ st.write(f"Nombre de nœuds : {nodes.shape[0]}")
49
  st.write(f"Nombre d'éléments : {elements.shape[0]}")
50
 
51
  # --- Optionnel : chargement des déplacements U (si tu les as dans un fichier) ---
52
- U = CAL.U
53
  if afficher_deplacement:
54
 
55
 
@@ -58,7 +59,8 @@ if afficher_deplacement:
58
 
59
  # avec 2*ne lignes (ux1, uy1, ux2, uy2, ...)
60
  try:
61
- U = np.loadtxt("U.txt")
 
62
 
63
  # à adapter
64
  if U.ndim > 1:
 
1
  import numpy as np
2
  import streamlit as st
3
  import plotly.graph_objects as go
4
+ import CAL_IA
5
+ from datasets import load_dataset
6
 
7
  st.set_page_config(page_title="Maillage FEM interactif", layout="wide")
8
 
 
50
  st.write(f"Nombre d'éléments : {elements.shape[0]}")
51
 
52
  # --- Optionnel : chargement des déplacements U (si tu les as dans un fichier) ---
53
+ U = CAL_IA.U
54
  if afficher_deplacement:
55
 
56
 
 
59
 
60
  # avec 2*ne lignes (ux1, uy1, ux2, uy2, ...)
61
  try:
62
+ U=np.loadtxt("U.txt")
63
+ # U = load_dataset("https://huggingface.co/datasets/ktongue/CT/blob/main/U.txt")
64
 
65
  # à adapter
66
  if U.ndim > 1:
config.yaml ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ ---
2
+ title: Mon App
3
+ sdk: streamlit
4
+ app_file: app.py
5
+ ---