Thermal conductivity varying with temperature shows error: Matrix is too large to convert to linear index.
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I am solving a steady state thermal model and want to vary thermal conductivity as a function of temperature for materials present in the model.
I have used
kp = @(location,state) 0.3049+0.006197*state.u-(1.153*10^-5)*(state.u).^2+(1.034*10^-8)*(state.u).^3-(3.352*10^-12)*(state.u).^4; % as function for variable thermal conductivity.
thermalProperties(model,"ThermalConductivity",kp,...
"Face", FaceID); % specific faces are assigned variable thermal conductivity
While solving model slover throws following error:
Matrix is too large to convert to linear index.
Error in pde.DiscretizedPDEModel/checkSpatialCoefsForUDependence (line 73)
self.cu = any(isnan(femat.K(:)));
Error in pde.DiscretizedPDEModel (line 36)
obj = obj.checkSpatialCoefsForUDependence(u0,tdummy);
Error in pde.ThermalModel/solve (line 139)
femodel = pde.DiscretizedPDEModel(self,p,e,t,coefstruct,u0,constCoeffsBCs);
Error in thermal_model_vary_pore_OL_limit_2_phase_updated (line 152)
results = solve(model);
The whole code is too long and uses 4-5 function to run :(
I have tried reducing the function for variable thermal conductivity to just linear (removing non-linear dependence on themperature) but it shows the same error.
Thanks in advance!
1 Commento
Ravi Kumar
il 2 Mag 2024
Hi Dron,
How large your mesh? You can display model.Mesh and look for size of Nodes property.
Regards,
Ravi
Risposte (1)
Sahas
il 19 Ago 2024
Modificato: Sahas
il 19 Ago 2024
As per my understanding, the model is adjusting thermal conductivity as a function on temperature and is having the error “Matrix is too large to convert to linear index” while solving the PDE.
I was able to generate the error using a sample script. I kept the “mesh” size very high, “state.u” in your code, which resulted in the creation of very large number of nodes and elements. This led to increased memory requirements to store the temperature values, “state.u”, and the subsequent resulting matrices.
With the limited information I have about the model, I recommend you try out the following workarounds and see if it resolves the error:
- Adjust the “mesh” size where you are defining the "state.u" to reducing the size of the subsequent matrices that are created.
- If most of the elements in the resulting matrices are zero, use MATLAB’s “sparse” function to store data in matrices more efficiently. A use case example is provided below.
A = eye(10000);
whos A
S = sparse(A);
whos S
Refer to the following MathWorks documentation links on “sparse” function for more information:
- https://www.mathworks.com/help/matlab/ref/sparse.html
- https://www.mathworks.com/help/matlab/math/sparse-matrix-operations.html
3. Consider using “single” precision data type to reduce memory usage.
I hope this is beneficial, feel free to ask additional questions.
0 Commenti
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!