Commit 3796acbd by Jeremy BLEYER

### Almost working nonlinear heat equation

parent afdaae79
 #!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Fri Feb 1 08:49:11 2019 @author: bleyerj """ from dolfin import * import mfront_wrapper as mf import numpy as np length = 30e-3 width = 5.4e-3 mesh = RectangleMesh(Point(0., 0.), Point(length, width), 100, 10) V = FunctionSpace(mesh, "CG", 1) T = Function(V, name="Temperature") def left(x, on_boundary): return near(x[1], 0) and on_boundary def right(x, on_boundary): return near(x[0], length) and on_boundary Tl = 300 Tr = 800 bc = [DirichletBC(V, Constant(Tl), left), DirichletBC(V, Constant(Tr), right)] facets = MeshFunction("size_t", mesh, 1) ds = Measure("ds", subdomain_data=facets) dt = Constant(1e-3) theta = Constant(0.5) material = mf.MFrontNonlinearMaterial("../materials/src/libBehaviour.so", "HeatTransfer", hypothesis="plane_strain") problem = mf.MFrontNonlinearProblem(T, material, quadrature_degree=0) problem.bc = bc j = mf.ThermalFlux(T) j.initialize_functions(mesh, 0) problem.flux = j H = mf.Flux(mf.Var(T), name="Enthalpy") H.initialize_functions(mesh, 0) problem.state_variables.append(H) H0 = H.previous() j0 = j.previous() problem.L = (problem.u_*(H.function - H0)-dt*(theta*dot(grad(problem.u_), j.function)+ -(1-theta)*dot(grad(problem.u_), j0)))*problem.dx problem.a = (problem.u_*H.tangents[0]*problem.du - dt*theta*dot(grad(problem.u_), j.tangents[0]*grad(problem.du) + j.tangents[1]*problem.du))*problem.dx print(problem.material.data_manager.K.shape) T.interpolate(Constant(Tl)) problem.solve(T.vector()) x = np.linspace(0, length) import matplotlib.pyplot as plt plt.plot(x, np.array([T(xi, width/2) for xi in x])) #plt.figure() #plot(project(flux.function[0], FunctionSpace(mesh, "DG",0))) \ No newline at end of file
 @DSL DefaultGenericBehaviour; @Behaviour HeatTransfer; @Author Thomas Helfer; @Date 15 / 02 / 2019; @Gradient TemperatureGradient gT; gT.setGlossaryName("TemperatureGradient"); @Flux HeatFlux j; j.setGlossaryName("HeatFlux"); @StateVariable real H; H.setEntryName("Enthalpy"); @AdditionalTangentOperatorBlock dj_ddT; @Parameter Tm = 933.15; @Parameter ks = 210; @Parameter Cs = 3.e6; @Parameter kl = 95; @Parameter Cl = 2.58e6; @Parameter dHsl = 1.08048e9; @LocalVariable thermalconductivity k; // @LocalVariable real H0; @LocalVariable real Ce; @Integrator { const auto T_ = T + dT; // const auto Te = temperature(0.01); // const auto Ts = Tm-Te; // const auto Tl = Tm+Te; // heat flux k = (T_::Id(); dj_ddT = tvector(real(0)); dH_ddT = Ce; } // end of @TangentOperator