Data-Driven Simulation
- Dominant language
- Julia
- Stars
- 879
- Forks
- 119
- Avg merge
- 6d 3h
- Merged PRs (30d)
- 4
Description
Hi,
After addressing some initial challenges, I must say that I love working with it. To get started, I explored the "Linear Elasticity" example available at [https://gridap.github.io/Tutorials/dev/pages/t003_elasticity/](https://chat.openai.com/url).
Now, I am working on implementing a fascinating concept called "Data Driven Computational Mechanics." Instead of relying on Hookes Law, I define a dataset $\mathcal{D}$ comprising pairs of strain-stress $(\hat{\epsilon}_i, \hat{\sigma}_i)$. My objective is to find the material state $(\epsilon, \sigma)$ that best matches the dataset while satisfying the equilibrium and kinematics equations.
The optimization problem can be formulated as follows:
$\min\limits_{(\hat{\epsilon}_i, \hat{\sigma}_i) \in \mathcal{D}} \frac{1}{2}\int (\hat{\epsilon}_i - \epsilon)^2 + (\hat{\sigma}_i - \sigma)^2 ,d\Omega$
subject to: $\mathrm{div} \sigma = f$ and $\epsilon = \nabla^{\text{sym}} u$.
While defining the equations is not an issue, my challenge lies in finding the data point in the dataset that yields the minimum distance from the material state during the simulation. I have tried using the following code, but it seems I cannot perform calculations directly on a CellField. Can somebody maybe help me regarding this?
```
using Gridap, PDENLPModels, Random, Distributions
### Material and Dataset
# Material parameters
const E = 70.0e9
const ν = 0.3
const λ = (E*ν)/((1+ν)*(1-2*ν))
const μ = E/(2*(1+ν))
σmat(ε) = λ*tr(ε)*one(ε) + 2*μ*ε
# Helper functions
function ToVoigt_sig(A)
return Gridap.VectorValue(A.data[1], A.data[2], A.data[3])
end
function ToVoigt_eps(A)
return Gridap.VectorValue(A.data[1], A.data[2], 2*A.data[3])
end
# Dataset
ndata = 100
eps = [TensorValue(rand(Uniform(-0.01,0.01), 2, 2)) for i in 1:ndata]
eps_vec = [ToVoigt_eps(epsi) for epsi in eps]
sig_vec = [ToVoigt_sig(σmat(epsi)) for epsi in eps]
### Domain and Spaces
# Domain
domain = (0,1,0,1)
partition = (10, 10)
model = CartesianDiscreteModel(domain,partition)
writevtk(model,"model")
labels = get_face_labeling(model)
add_tag_from_tags!(labels,"diri_0",[1,3,7])
add_tag_from_tags!(labels,"diri_1",[2,4,8])
degree = 2
Ω = Triangulation(model)
dΩ = Measure(Ω, degree)
# Solution space u
order = 1
reffeᵤ = ReferenceFE(lagrangian, VectorValue{2,Float64}, order)
Vᵤ = TestFESpace(model, reffeᵤ, conformity=:H1, dirichlet_tags = ["diri_0", "diri_1"])
disp_x = 0.01
g1 = VectorValue(0.0,0.0)
g2 = VectorValue(disp_x, 0.0)
U = TrialFESpace(Vᵤ,[g1,g2])
# Solution space σ
reffeₛ = ReferenceFE(lagrangian, VectorValue{3, Float64}, order)
Vₛ = TestFESpace(model, reffeₛ; conformity=:H1)
Σ = TrialFESpace(Vₛ)
# Multifield Space
X = MultiFieldFESpace([Vᵤ, Vₛ])
Y = MultiFieldFESpace([U, Σ])
### Simulation
# Objective Function (distance minimazation)
function f(u, σ)
## Here should be a minimizer to find the optimal data point in data set D = (eps_vec, sig_vec)
1/2*∫(*(eps_vec - (ToVoigt_eps∘ε(u)))⋅(eps_vec - (ToVoigt_eps∘ε(u))) + (sig_vec - σ)⋅(sig_vec - σ))*dΩ
end
# Constraints (div σ = f)
function res(u, σ, v)
∫(σ ⋅ (ToVoigt_eps∘ε(v)))*dΩ
end
# Solution simulation
op = FEOperator(res, Y, Vᵤ)
ndofs = Gridap.FESpaces.num_free_dofs(Y)
xin = zeros(ndofs)
nlp = GridapPDENLPModel(xin, f, Ω, U, Σ, Vᵤ, Vₛ, op, name = "Test")
```
Contributor guide
Research direction
Start with the CellField calculations in `f` and the `GridapPDENLPModels` setup, then compare the field representation with the linked Linear Elasticity tutorial. Identify a supported way to express the dataset minimization and define completion as a working data-driven simulation whose selected data point satisfies the stated constraints.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- backend, data
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100