Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6920325
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:07:56+00:00 2026-05-27T10:07:56+00:00

I encountered a memory problem in Mathematica when I tried to process my experimental

  • 0

I encountered a memory problem in Mathematica when I tried to process my experimental data. I’m using Mathematica to find the optimal parameters for a system of three partial differential equations.

When the e parameter was greater than 0.4, Mathematica consumed a lot of memory. For e < 0.4, the program worked properly.

I have tried using $HistoryLength = 0, and reducing AccuracyGoal and WorkingPrecision with no success.

I’m trying to understand what mistakes I made, and how I may limit the memory usage.

Clear[T, L, e, v, q, C0, R, data, model];
T = 13200; 
L = 0.085; 
e = 0.41; 
v = 0.000557197; 
q = 0.1618; 
C0 = 0.0256; 
R = 0.00075;

data = {{L, 600, 0.141124587}, {L, 1200, 0.254134509}, {L, 1800, 
    0.342888644}, {L, 2400, 0.424476295}, {L, 3600, 0.562844542}, {L, 
    4800, 0.657111356}, {L, 6000, 0.75137817}, 
       {L, 7200, 0.815876516}, {L, 8430, 0.879823594}, {L, 9000, 
    0.900771775}, {L, 13200, 1}};

model[(De_)?NumberQ, (Kf_)?NumberQ, (Y_)?NumberQ] := 
 model[De, Kf, Y] =  yeld /. Last[Last[
     NDSolve[{
       v D[Ci[z, t], z] + D[Ci[z, t], t] == -((
         3 (1 - e) Kf (Ci[z, t] - C0))/(
         R e (1 - (R Kf (1 - R/r[z, t]))/De))),
       D[r[z, t], t] == (R^2 Kf (Ci[z, t] - C0))/(
        q r[z, t]^2 (1 - (R Kf (1 - R/r[z, t]))/De)),
       D[yeld[z, t], t] == Y*(v e Ci[z, t])/(L q (1 - e)),
       r[z, 0] == R,
       Ci[z, 0] == 0,
       Ci[0, t] == 0,
       yeld[z, 0] == 0},
      {r[z, t], Ci[z, t], yeld}, {z, 0, L}, {t, 0, T}]]]

fit = FindFit[
  data, {model[De, Kf, Y][z, t], {0.97  < Y < 1.03, 
    10^-6 < Kf < 10^-4, 10^-13 < De < 10^-9}}, 
     {{De, 10^-12}, {Kf,  10^-6}, {Y, 1}}, {z, t}, Method -> NMinimize]

data = {{600, 0.141124587}, {1200, 0.254134509}, {1800, 
    0.342888644}, {2400, 0.424476295}, {3600, 0.562844542}, {4800, 
    0.657111356}, {6000, 0.75137817}, {7200, 0.815876516}, 
       {8430, 0.879823594}, {9000, 0.900771775}, {13200, 1}}; 

YYY = model[De /. fit[[1]], Kf /. fit[[2]], Y /. fit[[3]]]; 

Show[Plot[Evaluate[YYY[L, t]], {t, 0, T}, PlotRange -> All], 
 ListPlot[data, PlotStyle -> Directive[PointSize[Medium], Red]]]

Link to the .nb file: http://www.4shared.com/folder/249TSjlz/_online.html

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T10:07:57+00:00Added an answer on May 27, 2026 at 10:07 am

    I have a sneaking suspicion the reason why it’s failing on you is because you’re caching the results.

    Do you need to store every single solution that NDSolve is producing? I’m somewhat skeptical of whether this is useful or not for Findfit, since I highly doubt it would revisit a past result.

    Besides, it’s not like you’re talking about integers where there’s a finite domain you’re talking about. You’re using reals and even over the range you specify, there’s A LOT of different solutions possible. I don’t think you want to store each and every one of them.

    Rewrite your code so that instead of having:

    model[(De_)?NumberQ, (Kf_)?NumberQ, (Y_)?NumberQ] := 
     model[De, Kf, Y] =  yeld /. Last[Last[
         NDSolve[..]
    

    You instead have:

    model[(De_)?NumberQ, (Kf_)?NumberQ, (Y_)?NumberQ] := 
     NDSolve[..]
    

    By caching your previous results, you’re going to eat up memory like no tomorrow with FindFit. Typically it’s useful when you have a recurrence relation, but here I’d seriously advise against it.


    Some Notes:

    After running for 2415 seconds on my machine, Mathematica’s memory usage went from 112,475,400 bytes to 1,642,280,320 bytes with the caching.

    I’m currently running the code without the caching now.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have encountered a problem i cannot find a solution. I am using a
I've encountered the problem that accessing data stored in heap memory performs really slow
We encountered a problem with using Subversion on Windows. A developer committed a file
I've encountered somewhat of a problem in MEF's part lifetime which causes memory leaks
I had encountered a problem while using Loki::Singleton , Loki::SmartPtr , and std::vector under
I encountered a weird problem while using python multiprocessing library. My code is sketched
I wrote C++ for 10 years. I encountered memory problems, but they could be
Encountered a frustrating problem in our application today which came down to an ArrayIndexOutOfBounds
I encountered a problem when running some old code that was handed down to
I encountered a strange problem today. Whenever i put a breakpoint in one of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.