Replies: 54 comments
-
It's fine if most of the functionality are wrappers to stuff like https://docs.scipy.org/doc/scipy/reference/generated/scipy.integrate.RK45.html but I think having a consistent interface (easy to experiment with the methods and parameters) which is specifically designed for finite element calculations (e.g. use of mass matrices in Mu'(t) = Au(t) and especially sparse matrices) would be beneficial. |
Beta Was this translation helpful? Give feedback.
-
This is quite a big issue. I think getting the right abstraction could be very helpful but I fear that it's hard; not many packages get this right. Some of the big questions:
All of the above should really be outside the scope of scikit-fem but although I've been looking for a couple of decades, I haven't really found anything suitable. There's PETSc but it's a bit heavy. There was GarlicSim but it had already been abandoned before I found it. |
Beta Was this translation helpful? Give feedback.
-
On the
In Python this is naturally a generator, like def evolve(t: float,
u: np.ndarray) -> Iterator[Tuple[float, np.ndarray]]:
t, u = step(t, u)
yield t, u As mentioned in #529, this is a lot like the iteration of the (problem-specific) function I'm not sure why this isn't in while True:
yield x
x = func(x) (Here using this would involve packing the time |
Beta Was this translation helpful? Give feedback.
-
On the question of implicit dynamical systems, if one begins with the general implicit system defined by the function This can be solved howsoever (#119). This often involves the jacobian For linear systems, In general the idea would be to define a dynamical system by the function f (the residual) and its two partial derivatives with respect to its second and third arguments; i.e. the stiffness and mass matrices, K and M. |
Beta Was this translation helpful? Give feedback.
-
Solid mechanical problems often involve the second derivative with respect to time. These can always be reduced to larger first-order systems by appending the first derivative to the state. In practice, it is common though to treat the second-order system directly; e.g. as in the Newmark-beta method. I'm not sure whether the latter really offer much benefit. If so, the previous could be augmented by defining |
Beta Was this translation helpful? Give feedback.
-
In pacopy 0.1.2, as used in exx 23 and 27, a steady nonlinear system is defined by an object with
The closeness of this Generally though I prefer functions to methods and I've had to replace pacopy with something taking residual and jacobian (or jacobian-solver) functions as arguments rather than an object with those methods; otherwise I find myself always having to construct temporary objects on the fly. |
Beta Was this translation helpful? Give feedback.
-
I don't think this'll work will it? Does it assume dividing through by the mass matrix? As in converting Mu'(t) = Au(t) to u'(t) = M−1 Au(t)? This is a possibility, but not if the mass matrix is singular, as in incompressible Stokes flow. |
Beta Was this translation helpful? Give feedback.
-
Another consideration: coupling. Can one drive one system with the output of another? Can two or more systems be strongly coupled? The latter might lead to the concept of hierarchical systems. |
Beta Was this translation helpful? Give feedback.
-
Alright, that may not make sense. Would it work by caching the LU-decomposition of |
Beta Was this translation helpful? Give feedback.
-
If we are able to make interesting progress then we could eventually spin it off into a separate package. |
Beta Was this translation helpful? Give feedback.
-
So based on this, would the simple use of from skfem.ivp import evolve
for (k, u) in evolve(M, A, I=I, x=x, dt=1e-2):
if k > 10:
break
# possibly plot u or check convergence criteria Then various parameters to |
Beta Was this translation helpful? Give feedback.
-
A brief comment before getting back to this properly in the new year.
Actually I generally leave the class DynamicalSystem:
def step(h: float, t: float, x: ndarray) -> Tuple[float, ndarray]:
raise NotImplementedError
def evolve(h: float, t: float, x: ndarray):
while True:
yield t, x
t, x = self.step(h, t, x)
class LinearDynamicalSystem(DynamicalSystem):
M, L: spmatrix
theta: float = 0.5
def step(h, t, x):
x = ... # take a generalized trapezoidal step as in ex19
return t + h, x |
Beta Was this translation helpful? Give feedback.
-
One case in which the |
Beta Was this translation helpful? Give feedback.
-
Should we have
Edit: I suppose it doesn't matter because
is just as simple and maybe even more descriptive. |
Beta Was this translation helpful? Give feedback.
-
Yeah, scikit-fem/docs/examples/ex19.py Line 73 in 6e31b46 |
Beta Was this translation helpful? Give feedback.
-
`if name == 'main':
|
Beta Was this translation helpful? Give feedback.
-
plt3(what, what) |
Beta Was this translation helpful? Give feedback.
-
As in ex10 cited above, the two arguments are the mesh and the solution. (Or in this unsteady case a snapshot of the solution.) |
Beta Was this translation helpful? Give feedback.
-
`NameError Traceback (most recent call last) NameError: name 'u' is not defined |
Beta Was this translation helpful? Give feedback.
-
How can I change the theta rule method in order to implement to the CN or backward Ba^{n}+\frac{1}{2}t Aa^{n}=Ba^{n-1}-\frac{1}{2}t Aa^{n-1}+tb^{n-1/2} or Ba^{n} =& Ba^{n-1}-t A^{n} + t b^{n} |
Beta Was this translation helpful? Give feedback.
-
In ex10 the mesh is called m and the unknown deflection x; in ex19 the mesh is called mesh and the unknown temperature at any given time step is called u. The names are more or less arbitrary, as usual in mathematics and computation. |
Beta Was this translation helpful? Give feedback.
-
The theta method is already implemented in ex19; theta = 1/2 gives Crank–Nicholson, theta = 1 gives backward Euler. scikit-fem/docs/examples/ex19.py Lines 65 to 67 in 6e31b46 |
Beta Was this translation helpful? Give feedback.
-
I didn't put it right.I don't want theta rule |
Beta Was this translation helpful? Give feedback.
-
Crank–Nicolson and backward Euler are just special cases of the θ-rule. If you want to hard-code them, you could; e.g.
or
respectively. |
Beta Was this translation helpful? Give feedback.
-
`if name == 'main':
plots me all the graphs but I want only the last one |
Beta Was this translation helpful? Give feedback.
-
Try moving the plotting outside the for t, u in evolve(0.0, u_init):
pass
plot3(m,u)
plt.show() |
Beta Was this translation helpful? Give feedback.
-
Oh, I don't think you want show() |
Beta Was this translation helpful? Give feedback.
-
close the issue.thnka for everything.you are awesome |
Beta Was this translation helpful? Give feedback.
-
From #529 at 2020-12-24:
Beta Was this translation helpful? Give feedback.
All reactions