Different spaces for different variables

Dear, i’m a beginner to this program and I was trying to implement a problem linked to the 1D heat equation. According to the author, I need to use P1 to approximate the time variable and P3 for the space variable. However, when I define fespace I cannot indicate this information.

For example, if I write fespace Vh(QT, P1); Vh u, v, I understand that in both variables the approximation is being done by P1.

You can separate the spaces and variables, as

fespace Vh(QT,P1);
fespace Wh(QT,P2);
Vh u;
Wh v,b;

In this case u is P1, v and b are in P2

I’m trying to get the solution for the following problem:

problem heateq(u, v, solver = Cholesky)
= int2d(QT)( (A1 * u + A2 * dy(u) + A3 * dx(u) + A4 * dxx(u)) * (A1 * v + A2 * dy(v) + A3 * dx(v) + A4 * dxx(v)))
+ int2d(QT)((.5 - t)^(2 * alpha) * u * v * ((x >= .3) * (x <= .6))*one)
- int1d(QT, 1)((.5^alpha) * t0 * rho0 * v);

The author mentions that he used polynomials of the type P(K) = (P3,x ⊗ P1,t)(K).

However, if I write as you suggested, I understand that I would have to define two “u”, however, I don’t know how to adapt the problem, if this is the correct idea,

Probably you have only two variables t (real) and x (real 1d).

I think that you should understand the statement “P(K) = (P3,x ⊗ P1,t)(K)” by
u(t,x)=\frac{t^{n+1}-t}{t^{n+1}-t^n}u^n(x)+\frac{t-t^n}{t^{n+1}-t^n}u^{n+1}(x), for t^n<t<t^{n+1}
Then you need only to resolve u^n(x) for n=0,1... and x in an interval. Thus it is a 1d problem, and known u^n(x) you need to solve a 1d equation to get u^{n+1}(x) that needs to be P3.

Interesting. If I follow this suggestion, how should I consider the terms “dy(u)” and “dy(v)”, since these terms I used to indicate the derivative at t?

You replace the time derivative by a finite difference
\frac{du}{dt}\simeq \frac{u^{n+1}-u^n}{dt}
This is coherent with the above approximation of u(t,x).
If your equation is A_1u+A_2\partial_t u+A_3\partial_x u-A_4\partial^2_{xx}u=0, you should set

problem heateq(u,v)=

Here u stands for u^{n+1} and uold stands for u^n.

The problem I am solving is fourth order in space and second order in time. This problem is related to the null controllability property of the heat equation. I’m not directly solving the heat equation.

Ok then for second-order in time you need two unknowns u and z, and set \frac{u^{n+1}-u^n}{dt}=z^{n+1}, \frac{z^{n+1}-z^n}{dt}=...

Thank you very much. I will apply the suggestions.

Or, if it is more adapted to your problem
A_1u^{n+1}+A_2\frac{u^{n+1}-u^n}{dt}+A_3\partial_x u^{n+1}+A_4\partial^2_{xx}u^{n+1}=z^{n+1},
A_1z^{n+1}+A_2\frac{z^{n+1}-z^n}{dt}+A_3\partial_x z^{n+1}+A_4\partial^2_{xx}z^{n+1}=0,