Write WWD file in ASCII

Questions and discussion about applications, input, output and general user topics
hartanto
Posts: 26
Joined: Sun Oct 21, 2012 11:28 am
Security question 1: No
Security question 2: 92
Location: University of Sharjah

Write WWD file in ASCII

Post by hartanto » Thu Aug 06, 2020 3:23 pm

Hi,

Is there any option to print out the wwd file in ASCII?

Thanks in advance.

Donny

Ana Jambrina
Posts: 87
Joined: Tue May 26, 2020 5:32 pm
Security question 1: No
Security question 2: 7

Re: Write WWD file in ASCII

Post by Ana Jambrina » Thu Aug 06, 2020 5:34 pm

In Serpent 2.1.31 the WW mesh was switched to be written from ASCII to binary.
What information are you looking for? Source/current importances or the mesh itself?
- Ana

hartanto
Posts: 26
Joined: Sun Oct 21, 2012 11:28 am
Security question 1: No
Security question 2: 92
Location: University of Sharjah

Re: Write WWD file in ASCII

Post by hartanto » Thu Aug 06, 2020 7:02 pm

Hi Ana,

Thank you for your prompt reply.

I want to get the value of the importance in each mesh grid. Is there any easy way to print it out in ASCII?

Thanks in advance.

Ana Jambrina
Posts: 87
Joined: Tue May 26, 2020 5:32 pm
Security question 1: No
Security question 2: 7

Re: Write WWD file in ASCII

Post by Ana Jambrina » Fri Aug 07, 2020 11:49 pm

Mimicking the ‘wwd’ binary file, source/current cell importances can be easily outputted (in Matlab format). In fact, a response-matrix solver debugging option with this feature will be included in the upcoming version Serpent 2.1.32, following the current response-matrix solver solution, source and response; and response-matrix solver currents.
However, the following changes it would make to get it printed: --> input file: 'set rmxtest 3' and sources (applied to version 2.1.31), as follows:

readinput.c
  • substitute lines 8990-8992 by:

    Code: Select all

    if (k < np)
       WDB[DATA_RMX_TEST_MODE] =
         TestParam(pname, fname, line, params[k++], PTYPE_INT, 0, 3);
    
importancesolver.c
  • add after line 31:

    Code: Select all

    void WriteWWMfile(long);
    
  • add after line 51:

    Code: Select all

    /* Check corrector step */
    
    if (((long)RDB[DATA_BURN_STEP_PC] == CORRECTOR_STEP) &&                                       
        ((long)RDB[DATA_BURN_SIE] == NO))
       return;
    
  • add after line 1251:

    Code: Select all

    /* Check if written in ASCII file */
    
    if ((long)RDB[DATA_RMX_TEST_MODE] == 3)                                                   
    	WriteWWMfile(rmx);
    
  • add after line 1814:

    Code: Select all

    /*****************************************************************************/
    
    /***** Function for printing results in Matlab-format file *******************/
    
    void WriteWWMfile(long rmx)
    {
      long msh, ptr, n, ng;
      char outfile[MAX_STR];
      FILE *fp;
    
      /* Get number of energy groups */
    
      ng = (long)RDB[rmx + RMX_NG];
      CheckValue(FUNCTION_NAME, "ng", "", ng, 1, 100000);
    
      /* Open file */
    
      sprintf(outfile, "%s_wwd%ld.m", GetText(DATA_PTR_INPUT_FNAME),
              (long)RDB[DATA_BURN_STEP]);
      fp = fopen(outfile, "w");
     
      /* Print number of energy groups */
    
      fprintf(fp, "ng = %ld;\n\n", ng);
    
      fprintf(fp, "imp_src = [\n");
    
      /* Loop over mesh */
    
      msh = (long)RDB[rmx + RMX_PTR_MESH_DATA];
      while (msh > VALID_PTR)
        {
          /* Source importance */
    
          ptr = (long)RDB[msh + RMX_CELL_IMP_SRC];
          CheckPointer(FUNCTION_NAME, "ptr", DATA_ARRAY, ptr);
    
          /* Print */
    
         for (n = 0; n < ng; n++)
            fprintf(fp, "%1.5E ", RDB[ptr + n]);
    
          fprintf(fp, "\n");
    
          /* Next */
    
          msh = NextItem(msh);
        }
    
      fprintf(fp, "];\n");
     
      fprintf(fp, "imp_curr = [\n");
    
      /* Loop over mesh */
    
      msh = (long)RDB[rmx + RMX_PTR_MESH_DATA];
      while (msh > VALID_PTR)
        {
          /* Source importance */
    
          ptr = (long)RDB[msh + RMX_CELL_IMP_CURR];
          CheckPointer(FUNCTION_NAME, "ptr", DATA_ARRAY, ptr);
    
          /* Print */
    
          for (n = 0; n < ng; n++)
            fprintf(fp, "%1.5E ", RDB[ptr + n]);
    
          fprintf(fp, "\n");    
    
          /* Next */
    
          msh = NextItem(msh);
        }
     
      fprintf(fp, "];\n");
    
      /* Close file */
    
      fclose(fp);
    }
    
    
Last edited by Ana Jambrina on Sat Aug 08, 2020 7:56 pm, edited 1 time in total.
- Ana

hartanto
Posts: 26
Joined: Sun Oct 21, 2012 11:28 am
Security question 1: No
Security question 2: 92
Location: University of Sharjah

Re: Write WWD file in ASCII

Post by hartanto » Sat Aug 08, 2020 6:28 pm

Thank you for your quick fix, Ana.

I modified the readinput.c and importancesolver.c from Serpent 2.1.31 as you suggested. I compiled and tested my input file after adding set rmxtest 3 into the input. The input ran without any problem but the wwd.m was not printed out.

To test the modified sss2.1.31, I changed my input to read directly the last wwd file generated using wwgen iteration following the last example from the tutorial on http://serpent.vtt.fi/mediawiki/index.p ... _reduction

Did I miss something? Many thanks for your support.

Ana Jambrina
Posts: 87
Joined: Tue May 26, 2020 5:32 pm
Security question 1: No
Security question 2: 7

Re: Write WWD file in ASCII

Post by Ana Jambrina » Sat Aug 08, 2020 8:02 pm

Yes, you are right. The lines I specified to make the modifications in importancesolver.c did not correspond with Serpent 2.1.31 raw version. Check the previous post, I corrected the lines there. Post here if you find any problem with it.
- Ana

hartanto
Posts: 26
Joined: Sun Oct 21, 2012 11:28 am
Security question 1: No
Security question 2: 92
Location: University of Sharjah

Re: Write WWD file in ASCII

Post by hartanto » Sat Aug 08, 2020 9:02 pm

It did not work. Similarly, the run went well, but the wwd.m file was not printed out. I did the modification again using the original importancesolver.c.

Ana Jambrina
Posts: 87
Joined: Tue May 26, 2020 5:32 pm
Security question 1: No
Security question 2: 7

Re: Write WWD file in ASCII

Post by Ana Jambrina » Sat Aug 08, 2020 9:15 pm

I just tested with the example from Wiki: VR simple approach, and it does work; however, it will not print out with VR iteration.
Let me know if that works for you or not. Maybe we can figure something else out.
- Ana

hartanto
Posts: 26
Joined: Sun Oct 21, 2012 11:28 am
Security question 1: No
Security question 2: 92
Location: University of Sharjah

Re: Write WWD file in ASCII

Post by hartanto » Sat Aug 08, 2020 9:18 pm

I did not do iteration. My input read the wwd file generated from serpent wwgen.

Ana Jambrina
Posts: 87
Joined: Tue May 26, 2020 5:32 pm
Security question 1: No
Security question 2: 7

Re: Write WWD file in ASCII

Post by Ana Jambrina » Sat Aug 08, 2020 9:21 pm

The modifications I suggested will not convert the binary into Matlab-format. Will write the file itself when running VR.
- Ana

Post Reply