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

Re: Write WWD file in ASCII

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

I tried, it worked well with the example problem. Let me do more tests and I will let you know. Many thanks for your time and support.

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:40 pm

Thank you so much, Ana. It worked well. Thank you again.

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 » Sun Aug 09, 2020 12:55 am

Maybe this option is more helpful/general (there is no need to modify at all the input file, when the wwd binary file is printed, also the Matlab file with the source/current importances is outputted): on Serpent 2.1.31 version make the following changes:

importancesolver.c: substitute line 256 and line 1251 by,

Code: Select all

     {
       WriteWWMesh(rmx);
       WriteWWMMesh(rmx);
     }
vrcycle.c: add after lines 106, 230, 366, 490

Code: Select all

     WriteWWMMesh(rmx);
header.h: add (i.e. after line 3064)

Code: Select all

     void WriteWWMMesh(long);
Makefile: add

Code: Select all

     writewwmmesh.o \

Code: Select all

     writewwmmesh.o: writewwmmesh.c header.h locations.h
         $(CC) $(CFLAGS) -c writewwmmesh.c
writewwmmesh.c: create a file naming it 'writewwmmesh.c' and include it with the rest of the sources

Code: Select all

/*****************************************************************************/

#include "header.h"
#include "locations.h"

#define FUNCTION_NAME "WriteWWMMesh:"

/*****************************************************************************/

void WriteWWMMesh(long rmx)
{
  long msh, ptr, n, ng; 
  FILE *fp;
  char outfile[MAX_STR];

  /* Get number of energy groups */

  ng = (long)RDB[rmx + RMX_NG];
  CheckValue(FUNCTION_NAME, "ng", "", ng, 1, 100000);

  /* Check corrector step */

  if (((long)RDB[DATA_BURN_STEP_PC] == CORRECTOR_STEP) &&
      ((long)RDB[DATA_BURN_SIE] == NO))
    return;  

  /* Open file */

  if (((long)RDB[DATA_BURNUP_CALCULATION_MODE] == NO) && 
      ((long)RDB[DATA_RUN_VR_ITER] == NO))
    sprintf(outfile, "%s_wwd.m", GetText(DATA_PTR_INPUT_FNAME));
  
  else if ((long)RDB[DATA_BURNUP_CALCULATION_MODE] == YES)
    sprintf(outfile, "%s_wwd%ld.m", GetText(DATA_PTR_INPUT_FNAME),
            (long)RDB[DATA_BURN_STEP]);
  
  else if  ((long)RDB[DATA_RUN_VR_ITER] == YES)
    sprintf(outfile, "%s_wwd%ld.m", GetText(DATA_PTR_INPUT_FNAME),
            (long)RDB[DATA_VR_ITER_IDX]);
      
  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);
}

/*****************************************************************************/
- Ana

Post Reply